【问题标题】:corrupted pdf file in pdf() in R when using ggarrange and do.call使用 ggarrange 和 do.call 时,R 中 pdf() 中的 pdf 文件损坏
【发布时间】:2021-03-15 02:30:19
【问题描述】:

我正在尝试使用

创建一个 pdf 输出
pdf("summary3.pdf",onefile=TRUE)
do.call(ggarrange, c(graphsList, list(ncol = 2, nrow=3, rremove("x.text"), align="hv" ) ))
dev.off

graphsList 是 qplot 对象的集合,这些对象是通过 this 循环得到的

emo_plot[[cor]] <- qplot(sentiment, xlab="Essay emotions", data=td_emo, weight=count, geom="bar",fill=sentiment)+ggtitle(pdfNames[cor])

生成的 summary.pdf 已损坏,无法打开。我读了

我需要一份打印声明。我试过了

f <- function(x){print(ggarrange(x))}
pdf("summary3.pdf",onefile=TRUE)
do.call(f, c(graphsList, list(ncol = 2, nrow=3, rremove("x.text"), align="hv" ) ))
dev.off

但我得到了错误

Error in (function (x)  : 
unused arguments (list(list(c("negative", "positive")

另外,当我尝试做 dev.off 时,我得到了这个

dev.off
function (which = dev.cur()) 
{
if (which == 1) 
stop("cannot shut down device 1 (the null device)")
.External(C_devoff, as.integer(which))
dev.cur()
}
<bytecode: 0x0000021967e8fc50>
<environment: namespace:grDevices>

有人有解决办法吗?

【问题讨论】:

  • 您的第一次尝试是正确的。使用dev.off() 而不是dev.off
  • 感谢罗纳克沙阿。这似乎是您发现的问题。顺便问一下,我该如何结束这个问题并感谢您?

标签: r pdf ggplot2 do.call


【解决方案1】:
pdf("summary3.pdf",onefile=TRUE)
do.call(ggarrange, c(graphsList, list(ncol = 2, nrow=3, rremove("x.text"), align="hv")))
dev.off()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-13
    • 1970-01-01
    • 2014-03-24
    • 2011-01-12
    • 2019-08-19
    • 1970-01-01
    相关资源
    最近更新 更多