Dear all,
I have a result my experiment like this below (here my toy example):
foo1 - list()
foo1[[1]] - c(10, 20, 30)
foo1[[2]] - c(11, 21, 31)
foo2 - list()
foo2[[1]] - c(100, 200, 300)
foo2[[2]] - c(110, 210, 310)
foo3 - list()
foo3[[1]] - c(1000, 2000, 3000)
foo3[[2]] - c(1100, 2100, 3100)
Are you trying to turn each of the components of foo into a matrix?
If that's it then:
lapply(foo, function(x) matrix(unlist(x), nrow = length(x)))
On 4/11/06, Muhammad Subianto [EMAIL PROTECTED] wrote:
Dear all,
I have a result my experiment like this below (here my toy example):
foo1 -
I forgot the byrow = TRUE. Try this instead:
lapply(foo, function(x) matrix(unlist(x), nrow = length(x), byrow = TRUE))
On 4/11/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
Are you trying to turn each of the components of foo into a matrix?
If that's it then:
lapply(foo, function(x)
If I understand what you want correctly:
foo1 - list(c(10,20,30), c(11,21,31))
foo2 - list(c(100,200,300), c(110,210,310))
foo3 - list(c(1000,2000,3000), c(1100,2100,3100))
fool - list(foo1, foo2, foo3)
lapply(fool, function(x) do.call('rbind', x))
[[1]]
[,1] [,2] [,3]
[1,] 10
Thank you very much for your useful suggestions.
These are exactly what I was looking for.
foo - list(foo1, foo2, foo3)
lapply(foo, function(x) matrix(unlist(x), nrow = length(x), byrow = TRUE))
or
lapply(foo, function(x) do.call('rbind', x))
Best, Muhammad Subianto
On 4/11/06, Muhammad
Thank you very much for your useful suggestions.
These are exactly what I was looking for.
foo - list(foo1, foo2, foo3)
lapply(foo, function(x) matrix(unlist(x), nrow = length(x), byrow = TRUE))
or
lapply(foo, function(x) do.call('rbind', x))
Best, Muhammad Subianto
On 4/11/06, Muhammad
One other thought. If they are all of the same dimension you could
alternately consider putting them into a 3d array:
library(abind)
abind(lapply(foo, function(x) do.call(rbind, x)), along = 3)
which may or may not have some advantage to you.
On 4/11/06, Muhammad Subianto [EMAIL PROTECTED]
Hello sir:
A question about the usage of list:
The data of a list:
[[1]]
genename comp diff lwr uprp.adj
g2-g1 NewU1-R g2-g1 -242.6667 -337.9602 -147.3732 1.754308e-04
g3-g1 NewU1-R g3-g1 -266.6667 -361.9602 -171.3732 8.869357e-05
g4-g1 NewU1-R g4-g1 440.6667
XinMeng wrote:
Hello sir:
A question about the usage of list:
The data of a list:
[[1]]
genename comp diff lwr uprp.adj
g2-g1 NewU1-R g2-g1 -242.6667 -337.9602 -147.3732 1.754308e-04
g3-g1 NewU1-R g3-g1 -266.6667 -361.9602 -171.3732 8.869357e-05
g4-g1