Try:
split(xm, row(xm))
On Nov 12, 2007 8:07 PM, Søren Højsgaard [EMAIL PROTECTED] wrote:
Dear List,
I want to turn the matrix
xm
[,1] [,2]
[1,] a b
[2,] d e
into a list by rows as:
[[1]]
[1] a b
[[2]]
[1] d e
A (bad?) way of doing this is as
unlist(apply(xm,1, list),
Try split:
x - matrix(letters[1:4], 2)
x
[,1] [,2]
[1,] a c
[2,] b d
split(x, row(x))
$`1`
[1] a c
$`2`
[1] b d
-Christos
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Søren Højsgaard
Sent: Monday, November 12, 2007 8:08 PM
To:
On Tue, 13 Nov 2007 02:07:39 +0100,
Søren Højsgaard [EMAIL PROTECTED] wrote:
Dear List, I want to turn the matrix
xm
[,1] [,2] [1,] a b [2,] d e
into a list by rows as: [[1]] [1] a b [[2]] [1] d e
A (bad?) way of doing this is as
unlist(apply(xm,1, list), recursive=F)
[[1]] [1] a b
3 matches
Mail list logo