r-RScript-ggplot()和ggsave()循环未在列表中迭代



我正试图使用一个带有ggplot((和ggsave((的循环,使用以下代码从单独的数据帧列表中创建一组图:

temp2 = list(gsub("*.txt.out$", "", list.files(pattern="*.out")))
for (i in 1:length(temp2)) {
Eg_cluster = temp2[[i]]
df = data.frame(eval(parse(text = Eg_cluster)))
myplot = ggplot(df, aes(xmin = start, xmax = end, y = molecule, fill = gene)) +
geom_gene_arrow() +
facet_wrap(~ molecule, scales = "free", ncol = 3) +
scale_fill_brewer(palette = "Set3") +
theme_genes() + ggtitle("snoRNA Cluster ", Eg_cluster)
ggsave(file = print(paste0(Eg_cluster, ".pdf")), plot = myplot, device = "pdf")
}

代码成功地从列表中的第一个数据帧输出了第一个绘图,但循环似乎没有遍历列表并在ggsave中生成其余的绘图。有人知道为什么剩下的情节没有输出吗?

非常感谢!

您正在使temp 2成为长度为1的列表。

temp2 = gsub("*.txt.out$", "", list.files(pattern="*.out"))

最新更新