【发布时间】:2021-06-01 17:28:52
【问题描述】:
我有一个正在运行的 R 脚本,它几乎完成了,但还有一个最后一个问题。我在 R 中使用 png(filename = " ", width = N, height = M, units =" ", ...) 函数,但它将宽度、高度和单位标志附加到 png 文件名。我在默认帮助中找不到解决此问题的方法。
我使用的确切命令是
for(i in 1:length(lst)){
png(paste0(filename = paste( lst[i]), ".png", width = 1280, height = 688, units = "px"))
...all plotting code...
dev.off()
}
其中lst[i] 是通过循环读取的文件名列表。我最终会调用 .png 文件
idq27qecq.png1280688px 其中 1280688px 是我在名称中不想要的东西。 png 文件也全部尺寸不正确,尺寸为 480 x 480 像素。
我该如何解决这个问题?
如果我在开头删除 paste0,我会收到错误
png 错误(文件名 = 粘贴(lst[i]),“.png”,宽度 = 1280,高度 = 688,: 'pointsize' 参数无效
还有
在 png(filename = paste(lst[i]), ".png", width = 1280, height = 688, 中: 强制引入的 NAs
修复我的输出图像的名称和大小的任何帮助都会有所帮助。 我看了这个帖子 save multiple plots r into separate jpg 但即使我尝试实现它也没有用。
所有这些都是通过脚本在 Rstudio 引擎中完成的。
【问题讨论】: