编织HTML不会在vignettes/中保存html [英] knit HTML does not save html in vignettes/

查看:63
本文介绍了编织HTML不会在vignettes/中保存html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个小插图vignettes/test-vignette3.Rmd:

---
title: "Sample Document"
output:
  html_document:
    highlight: kate
    theme: spacelab
    toc: yes
  pdf_document:
    toc: yes
---

Header
=========

当我按下knit HTML按钮时,我得到以下信息:

When I hit the knit HTML button, I get the following:

processing file: test-vignette3.Rmd
output file: test-vignette3.knit.md


Output created: /tmp/RtmpKVpegL/preview-5ef42271c0d5.dir/test-vignette3.html

但是,如果我将此文件复制到inst/doc并按knit HTML按钮,则会得到:

However, if I copy this file to inst/doc and hit the knit HTML button, I get:

processing file: test-vignette3.Rmd
output file: test-vignette3.knit.md


Output created: test-vignette3.html

我的问题是:

  1. 如何让RStudio将vignettes/test-vignette3.Rmwknit HTML的输出保存到vignettes目录?
  2. 如何使RStudio在knit HTML过程中不删除test-vignette3.knit.md? (我想要一个.md文件,以便人们可以在我的github存储库上阅读它.)
  1. How do I get RStudio to save the output from knit HTML on vignettes/test-vignette3.Rmw to the vignettes directory?
  2. How do I get RStudio to not delete test-vignette3.knit.md during the knit HTML procedure? (I'd like to have the .md so people can read it on my github repo.)

我正在运行RStudio版本0.98.836,rmarkdown版本0.1.98和knitr版本1.5.

I'm running RStudio version 0.98.836, rmarkdown version 0.1.98 and knitr version 1.5.

推荐答案

实际上,您不应该 将.html输出保留在vignettes/下,因为小插图输出应该由.如果在生成源包时HTML输出文件已经存在,R可能无法重新编译您的小插图,这意味着您可能会看到旧的(并且可能是错误的)结果,因为HTML文件不是从最新版本的HTML文件生成的. .Rmd文件.因此,RStudio特意避免将HTML文件写入vignetttes目录中.

Actually you should not keep the .html output under vignettes/, because the vignette output is supposed to be generated by R CMD build. R may fail to recompile your vignettes if the HTML output files have already been there when you build the source package, which means you are likely to see old (and possibly wrong) results because the HTML file was not generated from the latest version of the .Rmd file. Therefore RStudio intentionally avoid writing the HTML files in the vignetttes directory.

如果您选择忽略以上警告,则可以肯定地可以在R控制台中运行rmarkdown::render('your-vignette.Rmd').

If you choose to ignore the warning above, you can certainly run rmarkdown::render('your-vignette.Rmd') in the R console.

对于第二个问题,我也不建议您这样做,因为Github将markdown呈现给HTML的方式有所不同(与通过 rmarkdown 包进行的Pandoc转换相比).通常,程序包小插图显示在CRAN上,例如,参见CRAN上的编织页面.但是,由于rmarkdown软件包尚未在CRAN上,因此您目前无法使用小插图引擎knitr::rmarkdown(我想我们现在与CRAN版本相距不远).不过,您可以考虑将HTML文件推送到Github页面.

For the second question, I do not recommend you to do that, either, because Github renders the markdown to HTML differently (compared to the Pandoc conversion done through the rmarkdown package). Normally the package vignettes are shown on CRAN, see, for example, the knitr page on CRAN. However, because the rmarkdown package is not on CRAN yet, you cannot use the vignette engine knitr::rmarkdown at the moment (I guess we are not too far away from the CRAN release now). You can consider pushing the HTML files to Github pages, though.

这篇关于编织HTML不会在vignettes/中保存html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆