在R上使用servr :: jekyll()时,应将Rmd文件保存在哪里? [英] When using servr::jekyll() on R, where should I save my Rmd files?
问题描述
将Rmd文件放在根目录下(例如,在我的/knitr-jekyll/上),它们正在转换为md文件,而不是html文件.因此,它们显示为简单的降价文字. 我试图将它们放在/_source和/_posts上,但情况变得更糟,在这种情况下,我也没有得到md文件.
With the Rmd files on root (eg. on my /knitr-jekyll/) they are turning into md files, but not on html files. Thus, they appear as simple markdown text. I tried to put them on /_source and on /_posts but it get's worse, in this case I also don't get the md files.
推荐答案
我发现同时创建一个单独的文件夹可以解决此问题.
I found creating a separate folder all together solves the problem.
/kintr-jekyll/_rmd/test.Rmd
但是请记住,如果您使用标准的引导程序模板,则在将Rmd
编织为md
时,将编织到_post
文件夹.还要确保指定了图形输出.最简单的方法是编写一些为您完成此操作的函数:
But do remember that when you knit your Rmd
to md
that you knit to the _post
folder if you using the standard bootstrap template. Also make sure that you specified your figure output. Easiest is to write some function which does this for you:
KnitPost <- function(input, base.url = "/") {
require(knitr)
opts_knit$set(base.url = base.url)
fig.path <- paste0("figures/", sub(".Rmd$", "", basename(input)), "/")
opts_chunk$set(fig.path = fig.path)
opts_chunk$set(fig.cap = "center")
render_jekyll()
knit(input, envir = parent.frame())
最后,请确保在knitr-jekyll/_post
中的.md
文件中确保已清楚引用这些图.这应该在您的test.md
:
Lastly, go make sure in your .md
file in knitr-jekyll/_post
that the figures are clearly referenced. This should be within your test.md
:
<img align="middle" src="/figures/test/test_image.jpg">
此链接可能会有所帮助: R-Blogger关于jekyll的帖子
This link might help: R-Bloggers post about jekyll
这篇关于在R上使用servr :: jekyll()时,应将Rmd文件保存在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!