Aaron Day
2006-Jan-18 19:18 UTC
[R] Converting a Perl Array of Arrayrefs to an R array or matrix using RS Perl
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
Reasonably Related Threads
- RS-MySQL.h:32:19: fatal error: mysql.h: No such file or directory
- [LLVMdev] Addressing const reference in ArrayRef
- Rs. 4510/- Saving on Samsung Galaxy Ace Plus S7500
- RS-485 over a half duplex serial in Centos 6.5
- logical masking of a matrix converts it to a vector