Merge multiple data frames, given in a list
mergeAll(dataFrames, by, ..., dbg = TRUE)
dataFrames | list of data frames. If the list elements are named, the element names are used as suffixes in the column names, otherwise suffixes ".1", ".2", etc are used |
---|---|
by | vector of column names to be merged by, passed on to |
… | additional arguments passed to |
dbg | if |
data frame being the result of merging all the data frames given in
dataFrames by consecutively calling merge
peter <- data.frame(fruit = c("apple", "pear", "banana"), kg = 1:3) paul <- data.frame(fruit = c("banana", "apple", "lemon"), kg = c(10, 20, 30)) mary <- data.frame(fruit = c("lemon", "organger", "apple"), kg = c(22, 33, 44)) # By default only categories that are in all data frames are returned mergeAll(list(peter = peter, paul = paul, mary = mary), by = "fruit")#> merging table 2 / 3 ... ok. #> merging table 3 / 3 ... ok.#> fruit kg.peter kg.paul kg.mary #> 1 apple 1 20 44# Use the arguments supported by merge to change that behaviour mergeAll(list(peter = peter, paul = paul, mary = mary), by = "fruit", all = TRUE)#> merging table 2 / 3 ... ok. #> merging table 3 / 3 ... ok.#> fruit kg.peter kg.paul kg.mary #> 1 apple 1 20 44 #> 2 banana 3 10 NA #> 3 pear 2 NA NA #> 4 lemon NA 30 22 #> 5 organger NA NA 33