[R] rownames cannot allocate vector of size
Larson, TR
trl1 at york.ac.uk
Mon Feb 22 10:46:07 CET 2010
Hi,
On R 2.10.1 for Windows, when I do the following to duplicate the
structure of a large numeric matrix called matrix1:
matrix2 <- matrix(0,nrow=nrow(matrix1),ncol=ncol(matrix1))
and then
rownames(matrix2) <- rownames(matrix1)
I get a "cannot allocate vector of size xxMb" error
but if I instead do:
rnames <- list()
rnames <- rownames(matrix1)
matrix2 <- matrix(0,nrow=nrow(matrix1),ncol=ncol(matrix1),dimnames=rnames)
I get no error.
Of course both approaches work in R on Unix without memory limits. But
I'm intrigued about the apaprent difference in memory usage/allocation
for the two above approaches. Is there any explanation for this
difference in behaviour?
thanks
Tony
More information about the R-help
mailing list