Elb Elb - 4 years ago 93
R Question

Subset and combine elements of a list

I have a list of data.frames that looks like this:

...................................
$ 97 :'data.frame': 3 obs. of 2 variables:
..$ row: int [1:3] 97 97 97
..$ col: chr [1:3] "0" "0" "0"
$ 98 :'data.frame': 3 obs. of 2 variables:
..$ row: int [1:3] 98 98 98
..$ col: chr [1:3] "0" "0" "0"
$ 99 :'data.frame': 3 obs. of 2 variables:
..$ row: int [1:3] 99 99 99
..$ col: chr [1:3] "0" "0" "0"


I would like to subset only $ col rows and combine that in this way:

............
97: 0,0,0
98: 0,0,0
99: 0,1,0


Thank you in advance

Answer Source

use

do.call(rbind, lapply(lst,function(x) x$col))
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download