R :: bigmemory - how to create a big.matrix character?

I am trying to use the bigmemory package in R and I am stuck at the very beginning. I:

 temp <- matrix(paste("a",1:10), 5, 2) 

and get the character matrix. This is normal. But then I try:

 x <- as.big.matrix(temp, type="char") 

and I get a matrix full NA and the following message:

 Assignment will down cast from double to char Hint: To remove this warning type: options(bigmemory.typecast.warning=FALSE) Warning messages: 1: In as.big.matrix(temp, type = "char") : Casting to numeric type 2: In matrix(as.numeric(x), nrow = nrow(x), dimnames = dimnames(x)) : NAs introduced by coercion 3: In SetElements.bm(x, i, j, value) : 

I'm not sure what is going on, but big.matrix looks trying to convert all my texts into numbers, despite type = "char" . How to make it work?

+5
matrix r character r-bigmemory
source share
1 answer

This is a bit incorrect - big.matrix objects only store numeric data types. The char type is a C ++ data type used to store integer values ​​that represent ASCII character codes (one character, not a character string). To store character strings in big.matrix, you will have to recode the strings as numeric values ​​(or convert to factors and then to numeric values).

If you need to store character data in a very large data set, you may need to look in the "ff" package. In my experience, it has a steep learning curve and the documentation is somewhat lacking, but it has this functionality.

For more information about working with large data sets, you can check the look of the CRAN task here: http://cran.r-project.org/web/views/HighPerformanceComputing.html

+6
source share

All Articles