从命令行运行R脚本并将结果存储在子目录中 [英] Run an R-script from command line and store results in subdirectory

查看:206
本文介绍了从命令行运行R脚本并将结果存储在子目录中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从命令行(在Linux机器上)运行R脚本,并将结果存储在工作目录的子目录中.看起来像这样:

I want to run an R-script from the command line (on a Linux machine) and store the results in a subdirectory of the working directory. It looks like that:

./myscript.r [param 1] [param 2] [param 3]

给出3个二项式参数,总共有4个条件.我想将每个条件的结果存储在工作目录的子目录中.

Given 3 binomial parameters there are 4 conditions in total. I want to store the results of each condition in a subdirectory of the working directory.

是不是有一种优雅的方法?还是我真的需要将R脚本复制到每个子目录中?

Is there an elegant way to do that or do I really need to copy my R-script to every subdirectory?

推荐答案

Purcell,请尝试在计算机上保存并运行此脚本.提供一些不同种类和参数的组合.

Purcell,try saving and running this script on your computer. Provide it a few different kinds and combinations of arguments.

#!/usr/bin/Rscript
args <- commandArgs(TRUE)
print(args)
class(args)

例如,我跑了./test.R test=1 one=test.

将此命令与paste0()语句结合使用,将为您提供所需的功能,以根据提供的参数定制输出位置.

Using this command in combination with paste0() statements should give you what you need to tailor your output locations based on the parameters provided.

这篇关于从命令行运行R脚本并将结果存储在子目录中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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