[R] Converting a Perl Array of Arrayrefs to an R array or matrix using RS Perl
Aaron Day
adayf96 at ucla.edu
Wed Jan 18 20:18:07 CET 2006
Dear R/RS-Perl users,
I have a perl script in which I parse a large number of files and
construct an array of arrayrefs from the data in the files. I then
pass that construct to R using the RS Perl interface. I want to be
able to use the construct as an R array or matrix so that I can use the
R function colSums.
So far, I've tried constructing an R matrix with dummy values, and then
populating each row of the new matrix with the nested Arrays of the
passed construct. But that just converts the R matrix to type list, so
I get an error when I try the function colSums. I then tried
converting each nested Array using as.numeric() before putting the
values into the matrix. But for some reason as.numeric doesn't convert
the nested arrays to numeric, so I still get an error when I try
colSums. If I check the values (say matrix[1][1]) the correct values
are in the correct locations, but it still won't perform colSums.
I've been hammering away on this for longer than I would like to admit.
Any help you could provide would be greatly appreciated.
Best regards,
Aaron
More information about the R-help
mailing list