I want to run a self-defined function in the R file with name "run.plot.R" on a remote HPC with linux.
我想在带有linux的远程HPC上的名为“run.plot.R”的R文件中运行自定义函数。
I type the linux command :
我输入linux命令:
R CMD run.plot.R
But it seems the function code is not read by R from the file yet. How can I load the function file into R and then run it?
但似乎R还没有从文件中读取功能代码。如何将函数文件加载到R然后运行它?
2 个解决方案
#1
1
Three options are:
有三种选择:
Rscript run.plot.R
or
要么
R CMD BATCH run.plot.R
or use the littler
app, see http://dirk.eddelbuettel.com/code/littler.html
或使用更小的应用程序,请参阅http://dirk.eddelbuettel.com/code/littler.html
All three of these run in a non-interactive mode.
所有这三个都以非交互模式运行。
If you want to run interactively, either
如果您想以交互方式运行,也可以
R --file run.plot.R
or just start R via
或者只是启动R via
R
then once R is running
一旦R运行
source("run.plot.R")
However, all of the above assumes that run.plot.R
contains function code and the R calls to run those R functions.
但是,所有上述假设run.plot.R包含函数代码而R调用运行这些R函数。
Finally, given the filename, whether any plots are or can b generated will depend on how is running on the remote Linux servers, whether X is forwarding over the connection you are using, etc.
最后,给定文件名,是否生成任何绘图将取决于在远程Linux服务器上运行的方式,X是否通过您正在使用的连接进行转发等。
#2
0
I often use
我经常使用
R --vanilla -f <filename>
The --vanilla
flag is used to ensure a consistent R environment among multiple users. Depending on your needs, you may or may not want to use it.
--vanilla标志用于确保多个用户之间的一致R环境。根据您的需要,您可能会也可能不想使用它。
#1
1
Three options are:
有三种选择:
Rscript run.plot.R
or
要么
R CMD BATCH run.plot.R
or use the littler
app, see http://dirk.eddelbuettel.com/code/littler.html
或使用更小的应用程序,请参阅http://dirk.eddelbuettel.com/code/littler.html
All three of these run in a non-interactive mode.
所有这三个都以非交互模式运行。
If you want to run interactively, either
如果您想以交互方式运行,也可以
R --file run.plot.R
or just start R via
或者只是启动R via
R
then once R is running
一旦R运行
source("run.plot.R")
However, all of the above assumes that run.plot.R
contains function code and the R calls to run those R functions.
但是,所有上述假设run.plot.R包含函数代码而R调用运行这些R函数。
Finally, given the filename, whether any plots are or can b generated will depend on how is running on the remote Linux servers, whether X is forwarding over the connection you are using, etc.
最后,给定文件名,是否生成任何绘图将取决于在远程Linux服务器上运行的方式,X是否通过您正在使用的连接进行转发等。
#2
0
I often use
我经常使用
R --vanilla -f <filename>
The --vanilla
flag is used to ensure a consistent R environment among multiple users. Depending on your needs, you may or may not want to use it.
--vanilla标志用于确保多个用户之间的一致R环境。根据您的需要,您可能会也可能不想使用它。