mergeAll: Merge Multiple Data Frames

View source: R/merge.R

mergeAllR Documentation

Merge Multiple Data Frames

Description

Merge multiple data frames, given in a list

Usage

mergeAll(dataFrames, by, ..., dbg = TRUE)

Arguments

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 merge

...

additional arguments passed to merge

dbg

if TRUE (default) debug messages showing the process of merging are shown

Value

data frame being the result of merging all the data frames given in dataFrames by consecutively calling merge

Examples

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")

# Use the arguments supported by merge to change that behaviour
mergeAll(list(peter = peter, paul = paul, mary = mary), by = "fruit", all = TRUE)
  

KWB-R/kwb.utils documentation built on April 1, 2024, 7:12 a.m.