繁体   English   中英

如何以高分辨率保存 plot 然后在 RMarkdown 针织文件中显示

[英]How to save a plot at high resolution and then show it in the RMarkdown knitted file

尝试了以下代码:

png(filename = "forestv8aall.png",
    width = 2000,
    height = 1750,
    res = 135)

forest(allexpcollapsed,
       alim =c(-2, 4),
       xlim =c(-4, 5),
       ilab = totalexp$N.sample.size..post.attrition., 
       ilab.xpos = -2,
       xlab = "Omission-bias effect",
       cex = .8)

# Add headlines to the forest
op <- par(font=4)
text(-4,
     allexpcollapsed$k + 2,
     "Author(s), Year, and Study #",
     pos = 4,
     cex = .8)
text(5,
     allexpcollapsed$k + 2,
     "Observed [95% CI]",
     pos = 2,
     cex = .8)
text(-2,
     allexpcollapsed$k + 2,
     "Sample size",
     cex=.8)
par(op)
dev.off()

下面显示在 RMD Knitted 文件中:

## png 
##   2

不过,我能够在同一文件夹中看到 output png 文件。

如何解决这个问题,以便高分辨率 plot 也显示在 RMD 针织字文件中? 提前致谢!

最好使用 RStudio(使这一切变得更容易),创建一个 Rmd 文件并将您的 R 代码放入 R 块中。 要显示图像,只需使用以下语法(这将在 R 块之外):

![Optional replacement text](forestv8aall.png)

然后按下“编织”按钮,瞧!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM