pass data from Perl to R -
i want pass following data perl r , rescaled them (scale [0, 1] ) in r rescaler function , send them perl.
$m1 = 4; $m2 = 5.3; $m3 = 2; $m4 = 1; $m5 = 1.3; $m6 = 2;
i did:
my $r = statistics::r->new() ; $r->startr ; $r->set('data', $m1 . ',' . $m2 . ',' . $m3 . ',' . $m4 . ',' . $m5 . ',' . $m6); $r -> run(q` library(reshape); scaled_data <- rescaler(data, type="range"); `); $scaled_data = $r -> get('scaled_data'); print $scaled_data,"\n",$data,"\n"; $r->stopr();
but following error.
problem while running r command: library(reshape); scaled_data <- rescaler(data); error: x - mean(x, na.rm = true) : non-numeric argument binary operator calls: rescaler -> rescaler.default in addition: warning message: in mean.default(x, na.rm = true) : argument not numeric or logical: returning na execution halted
1) how can pass data correctly? 2) think approach, code work slowly, need send data r rescaling?
@len jaffe , @mrflick
i tried :
my $r = statistics::r->new() ; $r->startr; $r->set('data', [ $m1 , $m2 , $m3 , $m4 , $m5 , $m6 ] ); $r -> run(q`library(reshape);scaled_data <- rescaler(data)`); $scaled_data = $r -> get('scaled_data'); print $scaled_data,"\n"; $r->stopr();
i got :
array(0xdde3d0)
are sure don't want:
$r->set('data', [ $m1 , $m2 , $m3 , $m4 , $m5 , $m6 ] );
that's how set commands documented in perldoc statistics::r
Comments
Post a Comment