我想将12个图形绘制成一个图形。 现在我写了这段代码:
everyEleven <- split(Theoph,ceiling(seq(nrow(Theoph))/11))
everyEleven
# SUbject numbers
pos_vec = c(1,2,3,4,5,6,7,8,9,10,11,12)
# One plot
plot(everyEleven[[12]]$Time, everyEleven[[12]]$conc, type = "l", main = "Subject 1")
# Several plots
plot_list = list()
par(mfrow=c(2,6))
plot_list
for (i in length(everyEleven)) {
plot(everyEleven[[i]]$Time, everyEleven[[i]]$conc, type = "l", main = paste("Subject",pos_vec[i]), xlab= "Time", ylab= "Concenctration")
plot_list[[i]] = p
}
这让我得到了情节,但只保存了最后一个(第十二个),然后不保存其余的。我知道如何将所有图块一一保存到jpeg文件中,但是我正努力将所有12个图块保存在一个图中。有人可以帮忙吗?
答案 0 :(得分:2)
一个简单的错误,您不会在所有图上循环,而仅在最后一个图上循环。添加1:length()
for (i in 1:length(everyEleven)) { # added 1:
plot(everyEleven[[i]]$Time, everyEleven[[i]]$conc, type = "l", main = paste("Subject",pos_vec[i]), xlab= "Time", ylab= "Concenctration")
plot_list[[i]] = p
}