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

问题描述

我正在尝试使用

创建 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,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()

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...