【发布时间】:2020-10-05 03:35:21
【问题描述】:
我正在尝试对数据框列表进行两个 ggplots
我有这个清单:
list.function <- function() {
sample1 <- data.frame(gene_biotype= c("protein_coding", "lncRNA", "intronic"), counts = c(1, 1, 1))
sample2 <- data.frame(gene_biotype= c("protein_coding", "lncRNA", "intronic"), counts = c(2, 2, 2))
sample3 <- data.frame(gene_biotype= c("protein_coding", "lncRNA", "intronic"), counts = c(3, 3, 3))
sample4 <- data.frame(gene_biotype= c("protein_coding", "lncRNA", "intronic"), counts = c(4, 4, 4))
sapply(paste('sample', seq(1,4,1), sep=''), get, environment(), simplify = FALSE)
}
my.list3 <- list.function()
my.list3
我想做这两个情节
a = ggplot(sampleX, aes(y=count, x = gene_biotype, fill = gene_biotype)) + geom_bar(stat = "identity") +
xlab("Groups") +
ylab("Counts") +
theme_classic() +
ggtitle(paste0(samplenumber))
b = ggplot(sampleX, aes(y=count, x = gene_biotype, fill = gene_biotype)) + geom_bar(stat = "identity") +
xlab("Groups") +
ylab("Counts") +
theme_classic() +
ggtitle(paste0(samplenumber))
png(samplename, width = 10, height = 5, units = "in", res=200)
ggarrange(a, b)
dev.off()
然后将每个图形打印成 png
【问题讨论】: