knitr markdown 从项目文件夹中删除图像文件
knitr markdown removes image file from project folder
我有这个基本的 R markdown 文件:
---
title: 'test'
output:
html_document
---

可以在项目文件夹中找到文件test.png
。如果我第一次编译文档一切都很好:
|.................................................................| 100%
ordinary text without R code
/Applications/RStudio.app/Contents/MacOS/pandoc/pandoc +RTS -K512m -RTS /Users/nf/test/test_file.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output test_file.html --smart --email-obfuscation none --self-contained --standalone --section-divs --template /Library/Frameworks/R.framework/Versions/3.2/Resources/library/rmarkdown/rmd/h/default.html --variable 'theme:bootstrap' --include-in-header /var/folders/x0/87l48swx73lg569_81cctqt00000gp/T//RtmpYYJgwp/rmarkdown-stree426f43954e.html --mathjax --variable 'mathjax-url:https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --no-highlight --variable highlightjs=/Library/Frameworks/R.framework/Versions/3.2/Resources/library/rmarkdown/rmd/h/highlight
processing file: test_file.Rmd
output file: /Users/nf/test/test_file.knit.md
Output created: test_file.html
但是如果我第二次编译它(不改变任何东西)我得到这个错误:
|.................................................................| 100%
ordinary text without R code
processing file: test_file.Rmd
output file: /Users/nf/test/test_file.knit.md
/Applications/RStudio.app/Contents/MacOS/pandoc/pandoc +RTS -K512m -RTS /Users/nf/test/test_file.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output test_file.html --smart --email-obfuscation none --self-contained --standalone --section-divs --template /Library/Frameworks/R.framework/Versions/3.2/Resources/library/rmarkdown/rmd/h/default.html --variable 'theme:bootstrap' --include-in-header /var/folders/x0/87l48swx73lg569_81cctqt00000gp/T//RtmprFBDzb/rmarkdown-streef56b8e7e99.html --mathjax --variable 'mathjax-url:https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --no-highlight --variable highlightjs=/Library/Frameworks/R.framework/Versions/3.2/Resources/library/rmarkdown/rmd/h/highlight
pandoc: Could not fetch test.png
test.png: openBinaryFile: does not exist (No such file or directory)
Error: pandoc document conversion failed with error 67
Execution halted
如果我查看我的项目文件夹,图像 test.png
不见了。在文档的第一次编译过程中,图像被删除了。我每次都可以重现它。然后当然是第二次编译时缺少它。我在 R 块中加载的 .RData
文件也会发生这种情况。我什至试图将文件保存在一个单独的文件夹中,每次在我的项目文件夹中复制它们我编译我的文档(使用命令 file.copy()
)。但是随后外部文件夹中的文件也会消失。似乎降价文档中提到的每个文件都被删除或移动到其他地方。
我发现只有当 markdown 文件的名称包含像 test file.Rmd
这样的空格时才会发生这种情况。 Html 从该文件生成的页面被格式化为 test_file.html
所以我猜想发生了一些转换为不带空格的文件名。
我认为这是一个错误,我应该在一些错误跟踪器上报告,但由于我不知道这是关于 rmarkdown、knitr、pandoc、RStudio 还是其他东西,我 post 在这里。
我的会话信息:
R version 3.2.2 (2015-08-14)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11.2 (El Capitan)
locale:
[1] de_DE.UTF-8/de_DE.UTF-8/de_DE.UTF-8/C/de_DE.UTF-8/de_DE.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] knitr_1.11
loaded via a namespace (and not attached):
[1] tools_3.2.2
更新到 rmarkdown_0.9.2
根据这个问题修复了问题:https://github.com/rstudio/rmarkdown/issues/580
我有这个基本的 R markdown 文件:
---
title: 'test'
output:
html_document
---

可以在项目文件夹中找到文件test.png
。如果我第一次编译文档一切都很好:
|.................................................................| 100%
ordinary text without R code
/Applications/RStudio.app/Contents/MacOS/pandoc/pandoc +RTS -K512m -RTS /Users/nf/test/test_file.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output test_file.html --smart --email-obfuscation none --self-contained --standalone --section-divs --template /Library/Frameworks/R.framework/Versions/3.2/Resources/library/rmarkdown/rmd/h/default.html --variable 'theme:bootstrap' --include-in-header /var/folders/x0/87l48swx73lg569_81cctqt00000gp/T//RtmpYYJgwp/rmarkdown-stree426f43954e.html --mathjax --variable 'mathjax-url:https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --no-highlight --variable highlightjs=/Library/Frameworks/R.framework/Versions/3.2/Resources/library/rmarkdown/rmd/h/highlight
processing file: test_file.Rmd
output file: /Users/nf/test/test_file.knit.md
Output created: test_file.html
但是如果我第二次编译它(不改变任何东西)我得到这个错误:
|.................................................................| 100%
ordinary text without R code
processing file: test_file.Rmd
output file: /Users/nf/test/test_file.knit.md
/Applications/RStudio.app/Contents/MacOS/pandoc/pandoc +RTS -K512m -RTS /Users/nf/test/test_file.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output test_file.html --smart --email-obfuscation none --self-contained --standalone --section-divs --template /Library/Frameworks/R.framework/Versions/3.2/Resources/library/rmarkdown/rmd/h/default.html --variable 'theme:bootstrap' --include-in-header /var/folders/x0/87l48swx73lg569_81cctqt00000gp/T//RtmprFBDzb/rmarkdown-streef56b8e7e99.html --mathjax --variable 'mathjax-url:https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --no-highlight --variable highlightjs=/Library/Frameworks/R.framework/Versions/3.2/Resources/library/rmarkdown/rmd/h/highlight
pandoc: Could not fetch test.png
test.png: openBinaryFile: does not exist (No such file or directory)
Error: pandoc document conversion failed with error 67
Execution halted
如果我查看我的项目文件夹,图像 test.png
不见了。在文档的第一次编译过程中,图像被删除了。我每次都可以重现它。然后当然是第二次编译时缺少它。我在 R 块中加载的 .RData
文件也会发生这种情况。我什至试图将文件保存在一个单独的文件夹中,每次在我的项目文件夹中复制它们我编译我的文档(使用命令 file.copy()
)。但是随后外部文件夹中的文件也会消失。似乎降价文档中提到的每个文件都被删除或移动到其他地方。
我发现只有当 markdown 文件的名称包含像 test file.Rmd
这样的空格时才会发生这种情况。 Html 从该文件生成的页面被格式化为 test_file.html
所以我猜想发生了一些转换为不带空格的文件名。
我认为这是一个错误,我应该在一些错误跟踪器上报告,但由于我不知道这是关于 rmarkdown、knitr、pandoc、RStudio 还是其他东西,我 post 在这里。
我的会话信息:
R version 3.2.2 (2015-08-14)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11.2 (El Capitan)
locale:
[1] de_DE.UTF-8/de_DE.UTF-8/de_DE.UTF-8/C/de_DE.UTF-8/de_DE.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] knitr_1.11
loaded via a namespace (and not attached):
[1] tools_3.2.2
更新到 rmarkdown_0.9.2
根据这个问题修复了问题:https://github.com/rstudio/rmarkdown/issues/580