Pandoc不使用RStudio生成HTML文件 [英] Pandoc for generating html file not using RStudio

查看:172
本文介绍了Pandoc不使用RStudio生成HTML文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过下面的脚本生成html文件,该脚本是复杂源代码的一部分,但我不想在用户计算机上安装RStudio.

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.

我正在使用以下网址提供的pandoc:来自github的pandoc 和在Sys.setenv中使用此pandoc文件的路径引用:"C:/Users/用户名/AppData/Local/Pandoc".

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

如果我在Sys.setenv命令中使用RSTUDIO_PANDOC,则在下面的脚本中一切正常,但是如果Sys.setenv命令中的RSTUDIO_PANDOC使用了我不想使用的默认RStudio pandoc文件,我会感到困惑.是否可以通过RSTUDIO_PANDOC进行任何替换,以确保不需要在用户计算机上安装RStudio,并且只能引用从上面的链接下载的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.

推荐答案

您可以在R中使用包pander形式.尽管如此,我通常更喜欢自己安装pandoc并在需要时使用系统调用运行R的所有内容.

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

然后可以更轻松地调整pandoc参数,并确保运行已安装的版本.如果要创建文档的 tex pdf 版本,这也使事情变得更加容易.

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.

这篇关于Pandoc不使用RStudio生成HTML文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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