我试图处理不同的文件,比如 R 脚本的输入,为此我在 Perl 中使用了一个 foreach 循环,但是 R 向我发送了一个警告:
Problem while running this R command:
a <- read.table(file="~/Desktop/ncRNA/Data/Inputs/Boxplot_all/All/$newquery")
Error:
file(file, "rt") : cannot open the connection
Calls: read.table -> file
In addition: Warning message:
In file(file, "rt") :
cannot open file '/Users/cristianarleyvelandiahuerto/Desktop/ncRNA/Data/Inputs/Boxplot_all/All/$newquery': No such file or directory
Execution halted
我的代码是:
#!/usr/bin/perl
use strict;
use warnings;
use Statistics::R;
use Data::Dumper;
my $R = Statistics::R->new();
my @query = (
'~/Desktop/ncRNA/Data/Inputs/Boxplot_all/All/dvex_all_rRNA_ce.RF00001.txt',
'~/Desktop/ncRNA/Data/Inputs/Boxplot_all/All/dvex_all_rRNA_ce_60.RF00001.txt',
'~/Desktop/ncRNA/Data/Inputs/Boxplot_all/All/dvex_all_rRNA_ce_70.RF00001.txt',
'~/Desktop/ncRNA/Data/Inputs/Boxplot_all/All/dvex_all_rRNA_ce_80.RF00001.txt',
'~/Desktop/ncRNA/Data/Inputs/Boxplot_all/All/dvex_all_rRNA_ce_90.RF00001.txt'
);
foreach my $query(@query) {
my $newquery = $query;
$newquery =~ s/(.*)\/(dvex_all.*)(\.txt)/$2$3/g;
print "$newquery\n";
$R->run(q`a <- read.table(file="~/Desktop/ncRNA/Data/Inputs/Boxplot_all/All/$newquery")`);
$R->run(q`res <- summary(a$V2)`);
my $output_value = $R->get('res');
print "Statistical Summary = $output_value\n";
}
使用正则表达式,我更改了输入的名称,但 R 不将其识别为文件。我可以这样做吗?一些建议?谢谢!