L.Vaiz L.Vaiz - 8 months ago 73
R Question

Is there a limit on working with matrix in R with the Rcpp tool?

Im kind a new programming in R, and even more programming in c++. I was trying to develop a program in R to estimate a Spearman correlation with the Rcpp tool and the C++ developer. I did it, but it only works with matrix with less of a range between 45 00 - 50 000 vectors. I dont know why, but it only works with that dimension. I suppose thereĀ“s limit with that type of information, maybe if i work it like a dataframe? I would really apreciate if you someone gives me a hindsight. Thanks!


To repeat more succintly:

  1. You can have more than 2^31-1 elements in a vector.

  2. Matrices are vectors with dim attributes.

  3. You can have more than 2^31-1 elements in a matrix (ie n times k)

  4. Your row and column index are still limited to 2^31.

Example of a big vector:

R> n <- .Machine$integer.max + 100
R> tmpVec <- 1:n
R> length(tmpVec)
[1] 2147483747
R> newVec <- sqrt(tmpVec)