[R] Initializing SparseM matrix matrix.csc

roger koenker rkoenker at uiuc.edu
Fri Jun 18 16:29:56 CEST 2004


 > A <- as.matrix.csr(0,5,4)
 > A
An object of class "matrix.csr"
Slot "ra":
[1] 0

Slot "ja":
[1] 1

Slot "ia":
[1] 1 2 2 2 2 2

Slot "dimension":
[1] 5 4

 > A[3,4] <- 3
 > A
An object of class "matrix.csr"
Slot "ra":
[1] 0 3

Slot "ja":
[1] 1 4

Slot "ia":
[1] 1 2 2 3 3 3

Slot "dimension":
[1] 5 4
 > as.matrix(A)
      [,1] [,2] [,3] [,4]
[1,]    0    0    0    0
[2,]    0    0    0    0
[3,]    0    0    0    3
[4,]    0    0    0    0
[5,]    0    0    0    0


url:	www.econ.uiuc.edu/~roger        	Roger Koenker
email	rkoenker at uiuc.edu			Department of Economics
vox: 	217-333-4558				University of Illinois
fax:   	217-244-6678				Champaign, IL 61820

On Jun 18, 2004, at 9:20 AM, Wolski wrote:

> Hi!
>
> Would like to initialize a huge matrix.csc (Pacakge SparseM) with all 
> elements 0
> and afterwards set a few alements nonzero.
> The matrix which I like to allocate is so huge that I can not use
> A <- matrix(a,n1,p)
> before:
> A.csr <- as.matrix.csc(A)
> because I can not allocate such a huge matrix A.
> But I believe that the much more memmory efficient model in case of 
> csc matrix should do it for a sparse matrix.
>
>
> How to do this.
> Sincerely Eryk
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html




More information about the R-help mailing list