[R] Symmetric Matrix classes

Gad Abraham gabraham at csse.unimelb.edu.au
Fri Nov 27 03:45:00 CET 2009


I'd like to store large covariance matrices using Matrix classes.

dsyMatrix seems like the right one, but I want to specify just the
upper/lower triangle and diagonal and not have to instantiate a huge
n^2 vector just for the sake of having half of it ignored:

Dumb example:
M <- new("dsyMatrix", uplo="U", x=rnorm(1e4), Dim=as.integer(c(100, 100)))
diag(M) <- 1

This doesn't work:
M <- new("dsyMatrix", uplo="U", x=0, Dim=as.integer(c(100, 100)))
Error in validObject(.Object) :
  invalid class "dsyMatrix" object: length of x slot != prod(Dim)

Is there an easier way of doing this?


Gad Abraham
PhD Student, Dept. CSSE and NICTA
The University of Melbourne
Parkville 3010, Victoria, Australia
email: gabraham at csse.unimelb.edu.au
web: http://www.csse.unimelb.edu.au/~gabraham

More information about the R-help mailing list