使用Rmarkdown生成html文件非常实用,但是如果在Rstudio进行的话会有一段时间不能操作界面。
今天我尝试在linux系统用R命令行进行这个步骤,使用如下命令:
rmarkdown::render('index.Rmd',output_file='index.html')
但是却报错:
Error: pandoc version 1.12.3 or higher is required and was not found (see the help page ?rmarkdown::pandoc_available).
最后使用了Rstudio的pandoc解决了这个问题,欧耶✌️
-- 在Rstudio找出pandoc路径在哪里
Sys.getenv("RSTUDIO_PANDOC")
在linux R命令行里引入pandoc,再运行rmarkdown
Sys.setenv(RSTUDIO_PANDOC="/usr/lib/rstudio-server/bin/pandoc")
rmarkdown::render('index.Rmd',output_file='index.html')