dev ='png'不适用于knitr中的pdf输出 [英] dev='png' is not working for pdf output in knitr
问题描述
在默认设置中,knitr将使用'pdf'表示LaTeX输出,使用'png'表示HTML/markdown".但是,我可以在LaTeX输出的块选项中指定dev ="png".此功能对于减小大矢量图形(例如地图)的文件大小非常有用.
In the default setting, knitr will use "'pdf' for LaTeX output and 'png' for HTML/markdown". However, I can specify the dev = "png" in the chunk options for the LaTeX output. This feature is very useful to reduce the file size for big vector figure (e.g. maps).
在较早版本的knitr(可以为1.8.*,但不确定)中,我可以指定dev ="png"(以下示例适用于较早的版本).
In the previous version of knitr (could be 1.8.*, but not sure), I can specify the dev = "png" (the example below is working for earlier version).
今天,我从github(现在)安装了最新版本的knitr.但是dev ='png'不适用于pdf输出.我必须将png设备用于pdf输出,因为我有一些pdf格式的大矢量图形.
Today I installed the latest version of knitr from github (just now). But the dev='png' is not working for pdf output. I have to use png device for pdf output as I have some big vector figure in pdf format.
错误消息是:
Error in (function (filename = "Rplot%03d.png", width = 480, height = 480, :
unused argument (pdf = list(useDingbats = FALSE) Call: <Anonymous> ...
block_exec -> chunk_device -> dev_new -> do.call -> <Anonymous> Execution halted))
我该如何解决此问题?
这是我的示例:
---
output: pdf_document
---
```{r, echo=FALSE, dev='png'}
plot(cars)
```
谢谢您的任何建议.如果我的问题仍然不清楚,请告诉我.
Thanks for any advice. Please let me know if my question is still not clear.
这是我的会话信息.
R version 3.1.3 (2015-03-09)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=English_Australia.1252 LC_CTYPE=English_Australia.1252 LC_MONETARY=English_Australia.1252
[4] LC_NUMERIC=C LC_TIME=English_Australia.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] knitr_1.9.4
loaded via a namespace (and not attached):
[1] digest_0.6.4 evaluate_0.5.5 formatR_1.0 htmltools_0.2.6 rmarkdown_0.5.1 stringr_0.6.2
[7] tools_3.1.3 yaml_2.1.13
推荐答案
这是 knitr 中的错误.我只是已修复在
This is a bug in knitr. I just fixed it in the development version (v1.9.5). The reason for the failure was that the options for the pdf
device were passed to the png
device.
这篇关于dev ='png'不适用于knitr中的pdf输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!