包含带有R软件包的命令行脚本

包含带有R软件包的命令行脚本

本文介绍了包含带有R软件包的命令行脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有兴趣向我编写的名为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.

我的问题是

  1. 我应该如何以自动化的跨平台方式处理脚本的安装?
  2. 如何确保在此过程中保留文件权限?
  3. 脚本的shebang行应该是什么?我目前正在使用

  1. How should I handle installation of the script in an automated cross-platform way?
  2. How can I make sure that the file permissions are retained in this process?
  3. 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

两个后续问题

  1. 我可以将这些命令打包到R函数install_slidify_cli中吗?
  2. 如何为Windows用户镜像这些命令?
  1. Can I package these commands into an R function install_slidify_cli?
  2. 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软件包的命令行脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 02:14