Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在linux上提交R作业?_Linux_R_Simulation_Coupling - Fatal编程技术网

如何在linux上提交R作业?

如何在linux上提交R作业?,linux,r,simulation,coupling,Linux,R,Simulation,Coupling,我是R的工程师新手,有一个必须在linux上运行的脚本,我搜索了很多,但找不到在linux上运行脚本的简单命令。我必须将我的工程软件与R结合起来,所以我还需要在linux上运行它 My script name is myscipt.R and I want to use 2 cpus to run that script. 请帮我创业 致以最诚挚的问候。这对我很有用: R CMD BATCH myscript.R 例如,下面应该生成一个随机生成矩阵的.csv文件。我总是用“.R”扩展名来命

我是R的工程师新手,有一个必须在linux上运行的脚本,我搜索了很多,但找不到在linux上运行脚本的简单命令。我必须将我的工程软件与R结合起来,所以我还需要在linux上运行它

My script name is  myscipt.R and I want to use 2 cpus to run that script.
请帮我创业

致以最诚挚的问候。

这对我很有用:

R CMD BATCH myscript.R
例如,下面应该生成一个随机生成矩阵的.csv文件。我总是用“.R”扩展名来命名这个脚本,但我不确定这是否必要

要调用的脚本(名为“testscript.R”)包含以下代码行:

set.seed(1)
M<-matrix(runif(20),5,4)
write.csv(M, file="M.csv")
在我的机器上,这会生成“M.csv”文档,如下所示:

    "","V1","V2","V3","V4"
"1",0.2655086631421,0.898389684967697,0.205974574899301,0.497699242085218
"2",0.37212389963679,0.944675268605351,0.176556752528995,0.717618508264422
"3",0.572853363351896,0.660797792486846,0.687022846657783,0.991906094830483
"4",0.908207789994776,0.62911404389888,0.384103718213737,0.380035179434344
"5",0.201681931037456,0.0617862704675645,0.769841419998556,0.777445221319795
此外,还会生成一个“testscript.Rout”文件,提供R控制台输出:

R version 2.14.0 (2011-10-31)
Copyright (C) 2011 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: i386-pc-solaris2.10 (32-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

[Previously saved workspace restored]

> set.seed(1)
> M<-matrix(runif(20),5,4)
> write.csv(M, file="M.csv")
> 
> proc.time()
   user  system elapsed 
  9.075   0.257   9.362 
R版本2.14.0(2011-10-31)
版权所有(C)2011统计计算基础
ISBN 3-900051-07-0
平台:i386-pc-solaris2.10(32位)
R是免费软件,绝对没有保修。
在某些条件下,欢迎您重新分发。
键入“license()”或“license()”以获取分发详细信息。
R是一个有许多贡献者的协作项目。
键入“contributors()”以获取详细信息和
“引文()”介绍如何在出版物中引用R或R软件包。
对于某些演示,键入“demo()”;对于联机帮助,键入“help()”;或者
“help.start()”用于HTML浏览器界面的帮助。
键入“q()”退出R。
[以前保存的工作区已恢复]
>种子(1)
>M write.csv(M,file=“M.csv”)
> 
>过程时间()
用户系统运行时间
9.075   0.257   9.362 

希望这能更好地解释它。

据我所知,您无法控制脚本外部使用的并行化/CPU(核心)数量:它需要在脚本中进行编码(
help(package=“parallel”))
)或简单地说:
Rscript myscript.R
。不幸的是,这两个命令都不起作用,服务器也无法识别命令R或Rscript。有什么问题吗?@hamad khan-你能通过在控制台命令行中输入“R”来打开R吗?@marcinebox我正在linux服务器上使用它。。我输入命令,它将生成另外两个文件。。它的.Rdata和.Rout文件,但不运行它。。那有什么问题?。。我认为它运行不正常,可能是因为我是新手。@hamad khan-我希望更详细的答案(上面)能帮助你。我不知道为什么它不适合你。可能.Rdata对象就是您的输出?通过查看.Rout对象,您应该看到脚本中是否有任何部分存在问题。在任何情况下,请尝试上面的示例,看看您是否也能够生成M.csv文件。
R version 2.14.0 (2011-10-31)
Copyright (C) 2011 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: i386-pc-solaris2.10 (32-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

[Previously saved workspace restored]

> set.seed(1)
> M<-matrix(runif(20),5,4)
> write.csv(M, file="M.csv")
> 
> proc.time()
   user  system elapsed 
  9.075   0.257   9.362