Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/69.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
使用commandArgs向r文件传递参数在闪亮的应用程序中不起作用_R_Shiny - Fatal编程技术网

使用commandArgs向r文件传递参数在闪亮的应用程序中不起作用

使用commandArgs向r文件传递参数在闪亮的应用程序中不起作用,r,shiny,R,Shiny,以下内容正确打印“hello world”: main_script.R commandArgs <- function() "hello world" source('file_to_source.R') commandArgs为什么需要使用source?为什么不直接生成函数呢?如果要在脚本之间传递变量,就不应该覆盖commandArgs函数。在你的源文件中应该有一些函数,你可以用你喜欢的参数调用它们。如果您希望命令行参数可重用,那么它们不应该自动执行。经过检查,我可能应该将其作为函数

以下内容正确打印“hello world”:

main_script.R

commandArgs <- function() "hello world"
source('file_to_source.R')

commandArgs为什么需要使用
source
?为什么不直接生成函数呢?如果要在脚本之间传递变量,就不应该覆盖
commandArgs
函数。在你的源文件中应该有一些函数,你可以用你喜欢的参数调用它们。如果您希望命令行参数可重用,那么它们不应该自动执行。经过检查,我可能应该将其作为函数重写。谢谢你们两位。
word<-(commandArgs())
print(word)