使用Knitr和RStudio生成的html文件的默认位置发生奇怪的变化 [英] Default location of generated html file using knitr and RStudio varies strangely

查看:161
本文介绍了使用Knitr和RStudio生成的html文件的默认位置发生奇怪的变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

创建一个新的类型为package的RStudio项目.创建一个vignettes目录.

Create a new RStudio project of type package. Create a vignettes directory.

创建两个新的R Markdown模板.一个在软件包的顶层(与DESCRIPTION相同),另一个在vignettes目录中.将两者都编织为html.

Create two new R Markdown templates. One in the top level of the package (same level as DESCRIPTION) and one in the vignettes directory. knit both to html.

第一个.Rmd的结果html文件在包的最高级别上紧靠.Rmd.这是我所期望的行为.

The resulting html file for the first .Rmd is right next to the .Rmd, at the highest level of the package. This is the behavior I expect.

对我来说,第二个.Rmd的结果html文件放置在一个临时目录中,例如:

The resulting html file for the second .Rmd is, for me, placed in a temporary directory like:

/private/var/folders/mk/lh99bg295msg8myvcf5yczkc0000gn/T/RtmpDNga3D/preview-152834fe09ff.dir/Untitled.html

,而不是在vignettes目录中.

and not in the vignettes directory.

  1. 这是预期的行为吗?任何指向适当文档的指针都表示赞赏!

  1. Is this the intended behavior? Any pointers to the appropriate documentation appreciated!

是否有简单的方法可以更改此设置?我希望在顶层目录中看到的vignettes目录中的行为相同(创建hmtl并将其保留在此处).

Is there an easy way to change this? I would prefer the same behavior in the vignettes directory (create the hmtl and leave it right there) that I see in the top level directory.

我在Mac上.

推荐答案

是的,这是有目的的.这是为了防止您的vignettes文件夹被HTML文件弄得乱七八糟. RStudio将所有程序包文档Rmds渲染为临时文件.如果您感到好奇,则相关代码在这里:

Yes, this is intended. It's to keep your vignettes folder from becoming cluttered with HTML files. RStudio renders all package documentation Rmds to temporary files. If you're curious the relevant code is here:

没有选项可以更改此行为,但是只有在使用RStudio的程序包构建工具时,它才会起作用.如果要暂时禁用它,则可以转到项目选项",然后将构建工具"更改为无"(尽管这当然也会暂时禁用其他软件包构建功能!).

There's no option to change this behavior, but it only engages when you are using RStudio's package building tools. If you want to temporarily disable it, you can go to your Project Options and change Build Tools to None (although this will of course disable other package-building affordances temporarily as well!).

这篇关于使用Knitr和RStudio生成的html文件的默认位置发生奇怪的变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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