[R] Warning while subsetting using Matrix package
Martin Maechler
maechler at stat.math.ethz.ch
Thu Jul 6 09:32:31 CEST 2006
>>>>> "JohnT" == Thaden, John J <ThadenJohnJ at uams.edu>
>>>>> on Thu, 6 Jul 2006 00:02:10 -0500 writes:
JohnT> > # ...I had previously created a sparse matrix in triplet form:
JohnT> > str(x)
JohnT> Formal class 'dgTMatrix' [package "Matrix"] with 6 slots
JohnT> ..@ i : int [1:923636] 1 2 3 4 5 6 7 8 9 10 ...
JohnT> ..@ j : int [1:923636] 1 1 1 1 1 1 1 1 1 1 ...
JohnT> ..@ Dim : int [1:2] 600 4482
JohnT> ..@ Dimnames:List of 2
JohnT> .. ..$ : chr [1:601] "50" "51" "52" "53" ...
JohnT> .. ..$ : chr [1:4482] "1" "2" "3" "4" ...
JohnT> ..@ x : num [1:923636] 50.2 51.2 52.2 53.2 54.2 ...
JohnT> ..@ factors : list()
JohnT> >
JohnT> > # While subsetting x, I was surprised to get this warning:
JohnT> > y<-x[1:300,]
JohnT> Warning message:
JohnT> number of items to replace is not a multiple of replacement length
and later
JohnT> Sorry, I omitted background information:
JohnT> R version: 2.3.0
JohnT> OS: Windows XP
JohnT> CPU: Pentium III,
JohnT> RAM: 768 MB
You omitted the most pertinent information: The version of
'Matrix' you are using.
The latest released version of Matrix does *not* show the
behavior you mentioned.
{So I have now spent 20 minutes just because you did not update 'Matrix'..}
JohnT> Also, what command-line memory settings might prevent R from crashing
JohnT> while using the Matrix package to convert my 600 X 4482 dgTMatrix to the
JohnT> dgCMatrix class or to an expanded Matrix, via the as() function? I can
JohnT> do this with half of the matrix, 300 x 4482.
It's hard to believe that you get a "crash" when coercing to
'dgC' -- but of course this really depends how much memory you
have already goggled up by other large objects in your R
workspace, or by other applications running at the same time in
Windows. Coercing to a full matrix will of course require
8 * 601 * 4482 = 21549456 extra bytes just for the numbers.
That's only 21.5 Megabytes, so I wonder..
I have never seen R crashes from using 'Matrix', but then I
work with an operating system, not with M$ Windows.
Maybe you meant you got an error message "... memory allocation .."?
JohnT> Thanks,
JohnT> John T
More information about the R-help
mailing list