Pandoc for generating html file not using RStudio

不问归期 提交于 2019-12-14 01:04:16

问题


I'd like to generate html file via script below which is a part of complex source code but I don't want to install RStudio on users machine.

I'm using pandoc available at: pandoc from github and the reference for path to this pandoc file is used in Sys.setenv: "C:/Users/username/AppData/Local/Pandoc".

If I use RSTUDIO_PANDOC in Sys.setenv command, everything works fine in my script below but I'm just confused if RSTUDIO_PANDOC in Sys.setenv command uses default RStudio pandoc file which I don't wanna use. Is there any replacement by RSTUDIO_PANDOC to be sure I don't need RStudio to be installed on user's machine and I can refer only to pandoc file what I downloaded from the link above.

Sys.setenv(RSTUDIO_PANDOC="C:/Users/username/AppData/Local/Pandoc")
setwd("C:/Users/username/interactiveKnitr") # set path to .Rmd file
knit('knit.Rmd') # creates md file
render('knit.Rmd') # creates html file

Thank you very much for any of your explanation and help on this. I'm very new in this area.


回答1:


You can use the package pander form within R. Despite of that I usually prefer to install pandoc myself and to use a system call if I need to run everything form R.

knit (input = "file.Rmd", output = "file.md")
system ("pandoc file.md")

Then is easier to tune pandoc parameters and you make sure to run the version you have installed. It makes also things easier if you want to create tex or pdf version of the document.



来源:https://stackoverflow.com/questions/35935213/pandoc-for-generating-html-file-not-using-rstudio

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