是否可以在 RStudio 中为 R-script 指定命令行参数? [英] Is it possible to specify command line parameters to R-script in RStudio?

查看:41
本文介绍了是否可以在 RStudio 中为 R-script 指定命令行参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 RStudio 来编辑具有命令行参数的 R 脚本,例如,

I want to use RStudio to edit an R-script having command line parameters, e.g.,

my_rscript --dataset mydataset

然后将选项值读入 R 变量,例如,dataset,例如,使用 optparse 库.

and then to read the optiion value into an R variable, say, dataset, e.g., using optparse library.

但是,我在 RStudio 中找不到可以提供命令行的位置,因此我可以使用保存时的源"功能.相反,我必须在程序本身中对所有程序参数进行硬编码:

However, I could not find where acommand line can be provided in RStudio, so that I could use "Source on save" feature. Instead, I have to hardcode all program parameters in the program itself:

dataset <- "mydataset"

每次需要指定不同的数据时都需要修改脚本文本.

which requires modifying the script text each time I need to specify different data.

有人知道如何提供命令行信息吗?

Does anybody know how to provide a command line information?

推荐答案

我知道这个问题很旧,下面的链接也很旧,但它回答了这个问题.不,无法(或截至 2012 年 1 月 29 日)从 RStudio 访问命令行参数.

I know this question is old and the link below is old, but it answers the question. No, it's not possible (or wasn't as of Jan 29, 2012) to access command line arguments from RStudio.

链接https://support.rstudio.com/hc/communities/public/questions/200659066-Accessing-command-line-options-in-RStudio?locale=en-us

这篇关于是否可以在 RStudio 中为 R-script 指定命令行参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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