[R] transform large matrix into list
Stefan Mischke
mischke at sozpsy.unizh.ch
Tue Jun 7 15:28:26 CEST 2005
Ok, ok, I got it! Please don't laugh!
My question is the example from the posting guide! Which even includes
the answer.
How embarrassing...
Stefan
Am 07.06.2005 um 14:55 schrieb Stefan Mischke:
> Dear List
>
> I need to transform a large matrix M with many NAs into a list L with
> one row for each non missing cell. Every row should contain the cell
> value in the first column, and its coordinates of the matrix in column
> 2 and 3.
>
> M:
> x1 x2
> y1 1 2
> y2 4 5
> y3 7 8
>
> L:
> v x y
> 1 1 1
> 4 1 2
> 7 1 2
> 2 2 1
> 5 2 2
> 8 2 3
>
> I'm trying to do this with a loop, but since my matrix is quite large
> (around 10k^2) this just takes a very long time.
> There must be a more efficient and elegant way to do this. Any hints?
>
> Thanks,
> Stefan
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.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