如何将R变量传递给python函数的系统调用?
我已经用python编写了一个函数,它接受两个参数,其中一个是文件路径名。我已经将对这个python函数的调用封装在R中的一个循环中。我希望能够更新这个R for循环中的一个变量,并将这个变量的值作为文件路径名传递给python函数。我该怎么做 R代码:如何将R变量传递给python函数的系统调用?,python,r,Python,R,我已经用python编写了一个函数,它接受两个参数,其中一个是文件路径名。我已经将对这个python函数的调用封装在R中的一个循环中。我希望能够更新这个R for循环中的一个变量,并将这个变量的值作为文件路径名传递给python函数。我该怎么做 R代码: for (file in filenames) { file <- paste("/home/yyy/xx", file, sep="/") system('python pylib/filefunction.py &
for (file in filenames) {
file <- paste("/home/yyy/xx", file, sep="/")
system('python pylib/filefunction.py <TODO: file> divide') # divide is the 2nd argument
}
for(文件名中的文件){
文件我相信您可以再次使用粘贴
:
for (file in filenames) {
file <- paste('/home/yyy/xx', file, sep='/')
system(paste('python', 'pylib/filefunction.py', file, 'divide'))
}
如何将divide转换为字符串并将其连接到系统调用的末尾?(可能使用粘贴?)如果这不是正确答案,那么我不理解问题。(+1)
for (file in filenames) {
system(sprintf('python pylib/filefunction.py /home/yyy/xx/%s divide', file))
}