r - 从 R 中查找 pandoc 可执行文件
问题描述
rmarkdown::find_pandoc
帮助我们pandoc
在 RStudio 中运行表单时找到不需要指定任何环境变量的可执行文件:
## in Rstudio
!is.null(rmarkdown::find_pandoc()$dir)
# [1] TRUE
但是,当从普通 R 控制台运行相同的命令时,我得到:
### R console
!is.null(rmarkdown::find_pandoc()$dir)
# [1] FALSE
阅读文档 pf ?rmarkdown::find_pandoc()
,解释了为什么我得到这些结果:
dir: A character vector of potential directory paths under which ‘pandoc’ may be found. If not provided, this function searches for ‘pandoc’ from the environment variable RSTUDIO_PANDOC (the RStudio IDE will set this variable to the directory of Pandoc bundled with the IDE), the environment variable PATH, and the directory ‘~/opt/pandoc/’.
我现在想编写一个可以从命令行(特别是不能从内部RStudio
)运行的脚本,需要pandoc
找到它。根据帮助,我可以设置我PATH
以确保pandoc
也可以从命令行找到它,但是一旦我希望我的同事使用脚本,我必须确保他/她PATH
已相应设置并且我想避免这种情况。
但是,我知道每个人都Rstudio
安装了(虽然不是在同一个位置),所以如果我知道我的位置,RStudio
我也可以推导出pandoc's
位置。
是否有任何可靠的方法可以Rstudio
从控制台获取路径(即在不Rstudio
运行时)?
长话短说:Rstudio
即使它没有运行,我怎么能找到呢?
解决方案
推荐阅读
- amazon-web-services - Elastic Beanstalk:.ebextensions 未复制
- tiff - 经度、经度的 Rasterio Tiff 指数?
- python - 我如何在python中创建扭曲的图像
- python - 创建一个模拟 TextIOWrapper 用作子进程的中间人
- typescript - 如何在构造函数中使用设置器?
- c# - 用 Unity C# 中的钥匙打开门
- json - 如何从 JSON 中的属性读取值并传递给 Jenkinsfile 中的矩阵轴值?
- php - 如何在php中检索丢失的连接?
- python - django 模型可以有硬编码的无类型字段吗?
- node.js - 如何从 Google oAuth 令牌获取 Firebase ID 令牌