【问题标题】:saving pdf plots in a specific file in r将pdf图保存在r中的特定文件中
【发布时间】:2016-02-11 09:52:17
【问题描述】:

我创建了多个保存在列表中的图。 现在我想保存它们并保留它们在列表中的名称。 到目前为止,我的代码如下。

 pdfplots <- function(PlotList){
 L <- List()
    for (i in 1:length(L)){
    names(L[[i]]) <- paste0(names(PlotList), i)
    pdfPath <- (file = "~/Documents/MyFile/MyPlots, names(L[[i]])")
    myplot <- boxplot(PlotList[[i]]) 
 }
 dev.off()
 }

因此,我想获得一个保存在特定路径上的 pdf 图。 任何帮助将不胜感激

【问题讨论】:

  • 1.在pdfPath 行中,引号位于错误的位置。 2. 缺少pdf() 命令。 3. 使用lapply 循环列表。

标签: r pdf plot


【解决方案1】:

您应该使用pdf 函数。下面的块应该可以完成这项工作:

    pdfplots <- function(PlotList){
            for (i in 1:length(PlotList)){
            fullFileName = paste0("~/Documents/MyFile/MyPlots/", names(PlotList)[i],".pdf")
            pdf(fullFileName)
            boxplot(PlotList[[i]]) 
            dev.off()
            }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-08-03
    • 1970-01-01
    • 2017-07-11
    • 2018-12-22
    • 1970-01-01
    • 1970-01-01
    • 2018-11-29
    • 2011-01-17
    相关资源
    最近更新 更多