【发布时间】:2020-09-07 06:14:54
【问题描述】:
我有以下代码,但不明白为什么 for 循环不起作用。我是新手,如果这很明显,请原谅,但它实际上并没有生成一组组合图(就像下面更暴力的方法所做的那样),它只是单独打印出每个图
library(ggpubr)
graphs <- lapply(names(hemi_split), function(i){
ggplot(data=hemi_split[[i]], aes(x=type, y=shoot.mass))+
geom_point()+
facet_wrap(.~host, scales="free")+
theme_minimal()+
labs(title=i)
});graphs
for (i in 1:length(graphs)) {
ggarrange(graphs[[i]])
} ##not working
## this works, and is the desired output
ggarrange(graphs[[1]], graphs[[2]], graphs[[3]],
graphs[[4]], graphs[[5]], graphs[[6]],
graphs[[7]], graphs[[8]], graphs[[9]],
graphs[[10]], graphs[[11]])
谢谢!
【问题讨论】: