merge_multiple: Merge multiple 'data.frame's

Description Usage Arguments Details Examples

View source: R/merge_multiple.R

Description

Merge multiple data.frames

Usage

1
2
merge_multiple(x, by, all = FALSE, sort = TRUE, incomparables = NULL,
  include = NULL, exclude = NULL)

Arguments

x

a list of data.frames with at least one column in common

by

name of the column to be merged by, by default the full intersect of column names between data.frames

all

include all rows, including those with no match

sort

sort the output on the by column(s)

incomparables

values which cannot be matched.

include, exclude

numric, logical or character vector specifying which columns to include in or exclude from the merge

Details

If there are duplicate columns that aren't being used to merge by, one of two things will happen. If the parent data.frames of the duplicate columns are named, then that name will be appended to the relevant column names. If the data.frames aren't named, then the data.frames idices in the parent list are appended to the relevant column names.
Inclusion and exclusion are performed in sequence, so that if both include and exclude are specified, exclude acts on the result from include.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
dtf1 <- data.frame(ast=1:4, bar=1:4, kat=c("A", "B", "C", "D"))
dtf2 <- data.frame(ast=1:6, bar=1:6, jun=9:4)
dtf3 <- data.frame(ast=2:6, bar=2:6, kat=c("A", "B", "C", "D", "E"))
dtf4 <- data.frame(ast=3:4, bar=3:4)
dtf5 <- data.frame(ast=1:-3, bar=0:4, git=0:4)

ll <- list(d1=dtf1, d2=dtf2, dtf3, A=dtf4, dtf5)

merge_multiple(ll, by="bar")
merge_multiple(ll, by="bar", all=TRUE, include=1:2)
merge_multiple(ll, by="bar", all=TRUE, exclude="kat")
merge_multiple(x=ll, by=c("bar", "ast"), all=TRUE)

AkselA/R-ymse documentation built on March 21, 2020, 9:52 a.m.