2 2 3 3
> c[order(r)]
[1] 4 1 2 3 5
> v[order(r)]
[1] 1 2 1 3 1
--
David.
-Original Message-
From: Phil Spector
To: erickso...@aol.com
Cc: r-help@r-project.org
Sent: Thu, Aug 19, 2010 7:35 pm
Subject: Re: [R] Converting sparse matrix to data.frame in Matrix
package
This se
)
-Original Message-
From: Phil Spector
To: erickso...@aol.com
Cc: r-help@r-project.org
Sent: Thu, Aug 19, 2010 7:35 pm
Subject: Re: [R] Converting sparse matrix to data.frame in Matrix package
This seems to work, although it eliminates the sparseness of the storage:
> dimname
This seems to work, although it eliminates the
sparseness of the storage:
dimnames(a) = list(NULL,letters[1:5])
as.data.frame(as.matrix(a))
a b c d e
1 0 0 0 1 0
2 2 1 0 0 0
3 0 0 3 0 1
- Phil Spector
Statistic
I am able to create a coordinate list sparse matrix this way:
r = c(1,2,2,3,3)
c = c(4,1,2,3,5)
v = c(1,2,1,3,1)
a = sparseMatrix(i=r,j=c,x=v)
However, this results in an object that looks like this:
a
3 x 5 sparse Matrix of class "dgCMatrix"
[1,] . . . 1 .
[2,] 2 1 . . .
[
4 matches
Mail list logo