Problem running this R command:
g1 <- table[, 3];
Got the error:
wrong number of dimmensions
####
#!/usr/bin/perl
use strict;
use warnings;
use Statistics::R;
my @lines;
my $line;
my $csv_check = shift @ARGV; #Mark for csv check-----
@ARGV = $csv_check;
while ( defined( $line = <> ) )
{
push @lines, $line;
}
shift @lines;
save_array_output(@lines, ".out");
print "\@lines = \n @lines ";
my $R = Statistics::R->new() ;
$R->startR ;
$R->run('library(genetics);');
$R->run('setwd("/home/user/tests/");');
#$R->set( 'table', \@lines );
$R->run('table <- read.table("/home/user/tests/data_freq.txt.out");');
$R->run('g1 <- table[, 3];');
$R->run('meang1 <- mean(g1)');
$R->run('print(meang1);');
$R->run('write.table(g1, "g1.txt");');
$R->run('write.table(meang1, "meang1.txt");');
my $media = $R->get('meang1');
my $results1 = $R->get('g1');
print "\$results1 = ", $results1, "\n";
print "\$media = ", $media, "\n";
$R->stopR() ;
#-----------------------------------------------
sub save_array_output
{
@lines = @_;
my $mid_name = pop @lines;
my $output_name = $csv_check.$mid_name;
open(MYOUTFILE, ">:utf8", $output_name); # Open output file
print MYOUTFILE "@lines \n";
close(MYOUTFILE); # Close output file
}
####
Locus Alleles frequencies
Bet01 230 0.166666666666666657415
Bet01 238 0.500000000000000000000
Bet01 244 0.333333333333333314830
Bet05 101 0.285714285714285698425
Bet05 103 0.500000000000000000000
Bet05 105 0.142857142857142849213
Bet05 109 0.071428571428571424606
Bet06 138 0.055555555555555552472
Bet06 140 0.111111111111111104943
Bet06 146 0.833333333333333370341
Bet12 108 0.111111111111111104943
Bet12 110 0.055555555555555552472
Bet12 112 0.444444444444444419773
Bet12 114 0.277777777777777790114
Bet12 116 0.055555555555555552472
Bet12 118 0.055555555555555552472