问题描述
我有兴趣向我编写的名为Slidify的R包提供命令行界面.它使用Rscript
,我认为这将使其跨平台.脚本存储在子目录inst/slidify
中.为了从任何目录使用脚本,我将其路径添加到了.bash_profile
上,就像在Mac上一样.
I am interested in providing a command line interface to an R package called Slidify that I am authoring. It uses Rscript
and I think that would make it cross-platform. The scripts are stored in the subdirectory inst/slidify
. In order to use the script from any directory, I added its path to my .bash_profile
as I am on a Mac.
我的问题是
- 我应该如何以自动化的跨平台方式处理脚本的安装?
- 如何确保在此过程中保留文件权限?
-
脚本的shebang行应该是什么?我目前正在使用
- How should I handle installation of the script in an automated cross-platform way?
- How can I make sure that the file permissions are retained in this process?
What should the shebang line for the script be? I am currently using
#!/usr/bin/Rscript --vanilla --slave
我将对如何处理此问题的指针以及已经完成的R软件包的任何示例表示赞赏.为了确保这一点,我很清楚,用户只需在命令行中运行slidify generate slides.Rmd
,便可以从slides.Rmd
生成幻灯片.
I would appreciate pointers on how to handle this and any examples of R packages that already do it. Just to make sure, I am clear on how this would work, a user would be able to generate a slide deck from slides.Rmd
by just running slidify generate slides.Rmd
from the command line.
更新:
这是我从命令行在Mac上安装它的方式.我通过37个信号使用了出色的 sub 库来创建脚本.
Here is how I install it on a Mac from the command line. I use the excellent sub library by 37 signals to create the scripts.
echo "$(path/to/clidir/slidify init -)" >> ~/.bash_profileexec bash
echo "$(path/to/clidir/slidify init -)" >> ~/.bash_profileexec bash
两个后续问题
- 我可以将这些命令打包到R函数
install_slidify_cli
中吗? - 如何为Windows用户镜像这些命令?
- Can I package these commands into an R function
install_slidify_cli
? - How can I mirror these commands for Windows users?
推荐答案
爱'slidify
,所以很乐意提供帮助.
Lovin' slidify
so would be glad to help.
但是总之,你不能.
R软件包根本无法安装在$R_HOME
或所选库文件夹之外.将脚本运送到包装中,并告诉用户复制它.如果有更好的方法,请在 littler 包中加上前身/替代Rscript
长期使用它,并且roxygen
/roxygen2
也会发货.
R packages simply cannot install outside of $R_HOME
or the chosen library folder. Ship the script in the package, and tell users to copy it. If there was a better way, out littler package with predecessor / alternative to Rscript
would long have used it, and roxygen
/ roxygen2
would also have shipped something.
这篇关于包含带有R软件包的命令行脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!