check the following:
sapply(comb, "[[", "a")
# or
data.frame(
"names" = names(comb),
"value" = sapply(comb, "[[", "a"),
row.names = seq_along(comb)
)
I hope it helps.
Best,
Dimitris
Dimitris Rizopoulos
Biostatistical Centre
School of Public Health
Catholic University of Leuve
[EMAIL PROTECTED] said the following on 5/14/2008
12:40 PM:
Using R 2.6.2, say I have the following list of lists, "comb":
data1 <- list(a = 1, b = 2, c = 3)
data2 <- list(a = 4, b = 5, c = 6)
data3 <- list(a = 3, b = 6, c = 9)
comb <- list(data1 = data1, data2 = data2, data3 = data3)
So that a
Try this:
> data1 <- list(a = 1, b = 2, c = 3)
> data2 <- list(a = 4, b = 5, c = 6)
> data3 <- list(a = 3, b = 6, c = 9)
> comb <- list(data1 = data1, data2 = data2, data3 = data3)
> sapply(comb, "[[", "a")
data1 data2 data3
1 4 3
> # Also, this can be useful:
> comb[[c("data2", "b")]
Try this:
do.call(rbind, lapply(comb, '[', 'a'))
On Wed, May 14, 2008 at 4:40 PM, <[EMAIL PROTECTED]>
wrote:
> Using R 2.6.2, say I have the following list of lists, "comb":
>
> data1 <- list(a = 1, b = 2, c = 3)
> data2 <- list(a = 4, b = 5, c = 6)
> data3 <- list(a = 3, b = 6, c = 9)
> comb <
Using R 2.6.2, say I have the following list of lists, "comb":
data1 <- list(a = 1, b = 2, c = 3)
data2 <- list(a = 4, b = 5, c = 6)
data3 <- list(a = 3, b = 6, c = 9)
comb <- list(data1 = data1, data2 = data2, data3 = data3)
So that all names for the lowest level list are common. How can I most
5 matches
Mail list logo