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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/9.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
如何在perl程序中将R中创建的变量作为参数传递?_R_Perl_Arguments - Fatal编程技术网

如何在perl程序中将R中创建的变量作为参数传递?

如何在perl程序中将R中创建的变量作为参数传递?,r,perl,arguments,R,Perl,Arguments,我是R新手。我想访问在R中创建的变量/对象,作为在R中调用的perl程序的参数。 我有笔试,大概是这样的: setwd("some directory") text <- list.files(pattern = ".txt$") for (j in text) { print(j) } system("perl test.pl somearg", intern=TRUE) setwd(“某个目录”) text您可以构造一个字符串来传递给系统: system(sprintf("perl

我是R新手。我想访问在R中创建的变量/对象,作为在R中调用的perl程序的参数。 我有笔试,大概是这样的:

setwd("some directory")
text <- list.files(pattern = ".txt$")
for (j in text)
{
print(j)
}
system("perl test.pl somearg", intern=TRUE)
setwd(“某个目录”)

text您可以构造一个字符串来传递给
系统

system(sprintf("perl test.pl %s", j))

%s
(s表示字符串)被
j

的内容替换,不确定您要做什么以及最终目标是什么,但另一种方法可能是用Perl编写程序,并使用Statistics::R模块来处理R内容。我最近一直在这样做,对于简单的操作来说,它非常灵活。是的,我也用这种方式尝试过。。!!它起作用了。。谢谢……)