igelkott has asked for the wisdom of the Perl Monks concerning the following question:
It's easy enough to load scalers and simple arrays into R through Statistics::R but I'm having trouble with multidimensional arrays. The manual doesn't actually claim to support this but maybe someone has managed.
Arrays are passed to R by reference (to make a simple list in R). Passing a reference to a multidimensional array produces a list of array tags. For example:
produces:use Statistics::R; use Data::Dumper; my @arr = qw(foo bar baz); my @mat = (["fred", "barney", "pebbles", "bambam"], ["george", "jane", "elroy", "judy"], ["homer", "bart", "marge", "maggie"]); my $R = Statistics::R->new(); $R->set('arr', \@arr); $R->set('mat', \@mat); my $r_arr = $R->get('arr'); my $r_mat = $R->get('mat'); print "Array:\n", Dumper($r_arr); print "Matrix:\n", Dumper($r_mat);
Array: $VAR1 = [ 'foo', 'bar', 'baz' ]; Matrix: $VAR1 = [ 'ARRAY(0x7fdbf4007328)', 'ARRAY(0x7fdbf4014b80)', 'ARRAY(0x7fdbf4014c58)' ];
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: multidimensional array in Statistics::R
by BrowserUk (Patriarch) on Feb 07, 2013 at 14:03 UTC | |
by igelkott (Priest) on Feb 07, 2013 at 17:38 UTC |
Back to
Seekers of Perl Wisdom