'Plot data based on three objects as z-scores
- I'm using the package "networktools" in R (https://cran.r-project.org/web/packages/networktools/networktools.pdf).
- I've created three "bridge"-objects: DataT5_SDQ_network_b, DataT6_SDQ_network_b, and DataT7_SDQ_network_b.
- The three bridge-objects are downloadable here: https://drive.google.com/file/d/12Hgq78RjuXXRLplIXJw6SNU4NoZbULcc/view?usp=sharing.
- The code which generates a bridge-object (using networktools): DataT5_SDQ_network_b <- bridge(DataT5_SDQ_network, communities=SDQ_communitiesSG, directed=FALSE, nodes = DataT5_SDQ_list$names)
I have successfully plotted the three "bridge"-objects in the same plot (with legend) using this code:
p <- lapply(list(DataT5_SDQ_network_b,
DataT6_SDQ_network_b,
DataT7_SDQ_network_b), function(x) suppressWarnings(plot(x)))
p <- Map(function(a, b) { a$data$Class <- b; a}, a = p, b = c("T5", "T6", "T7"))
p[[1]]$data <- do.call(rbind, lapply(p, function(x) x$data))
p <- p[[1]] + aes(color = Class, group = Class)
p
Questions:
- How can I plot the data as z-scores?
- How can I get the plot only showing Bridge Expected Influence (1-step)?
Solution 1:[1]
I found out:
First, plot each plot:
gg1 <- plot(DataT5_SDQ_network_b, include=c("Bridge Expected Influence (1-step)"), theme_bw=FALSE, zscore=TRUE)
gg2 <- plot(DataT6_SDQ_network_b, include=c("Bridge Expected Influence (1-step)"), theme_bw=FALSE, zscore=TRUE)
gg3 <- plot(DataT7_SDQ_network_b, include=c("Bridge Expected Influence (1-step)"), theme_bw=FALSE, zscore=TRUE)
Then combine plots
p <- list(gg1, gg2, gg3)
p <- Map(function(a, b) { a$data$Class <- b; a}, a = p, b = c("T5", "T6", "T7"))
p[[1]]$data <- do.call(rbind, lapply(p, function(x) x$data))
p <- p[[1]] + aes(color = Class, group = Class)
p
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Brage Kraft |