String connecting dataset set?

I read the list of datasets and named it n. What I want to do is take a subset of the datasets from n and the string, link them together in R. When I try to jump rbind(n), it just gives me a data frame of all dataset names instead of actually placing the elements of each dataset under each other. What I want to do is bind subsets of datasets that have a common name. For example, 18 data sets start with "4". and I want to tie it all together. Is there an easy way to do this?

+5
source share
2 answers

Want you to do this rbind(n[[1]],n[[2]],...), which does not match rbind(n).

, do.call call

 do.call(rbind, n)

.

rbindlist data.table,

 library(data.table)

 rbindlist(n)

, 4

rbindlist(n[grep(names(n), pattern = '^4')])
+11

, rbind.fill plyr- (i don'konw, data.table)

ll <- list(a=data.frame(x=1,y=2,z=1),
         b= data.frame(x=2,y=3),
         c=data.frame(x=3:4,y=5))

library(plyr)
Reduce(rbind.fill,ll[c('a','b')])   ## subset by list names and 
                                    ## apply recursively using Reduce
  x y  z
1 1 2  1
2 2 3 NA
+1

All Articles