When using servr::jekyll() on R, where should I save my Rmd files?

孤街浪徒 提交于 2019-12-13 02:12:54

问题


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.


回答1:


I found creating a separate folder all together solves the problem.

/kintr-jekyll/_rmd/test.Rmd

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())

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">

This link might help: R-Bloggers post about jekyll



来源:https://stackoverflow.com/questions/35047164/when-using-servrjekyll-on-r-where-should-i-save-my-rmd-files

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!