使用 ggarrange 和 do.call 时,R 中 pdf() 中损坏的 pdf 文件

corrupted pdf file in pdf() in R when using ggarrange and do.call

我正在尝试使用

创建 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 对象的集合

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>

有人有解决办法吗?

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