merge.x: merge.x

Description Usage Arguments Value Author(s) Examples

View source: R/pub01_utilityFuncs.R

Description

Just same with merge, except that: (1) the order of merging result is kept same with x;(2)speed up by using merge.data.table.

Usage

1
2
3
## S3 method for class 'x'
merge(x, y, by = intersect(colnames(x), colnames(y)),
  mult = "all")

Arguments

x

a data frame

y

a data frame

by

a vector of shared column names in x and y to merge on.

mult

a character string: one of "all","first","last". See detail in data.table

Value

a new data.frame based on the merged data tables, sorted by the x order.

Author(s)

Ruifei.Yin

Examples

1
2
3
4
5
6
7
x <- data.frame(k1=c(1,5,3),k2=c("a","a","c"),V=11:13)
y <- data.frame(k1=c(2,3,1,5,6),k2=c("b","c","a","f","x"),v1=LETTERS[1:5],v2=LETTERS[8:12])
# compare the following result:
merge.x(x,y)
merge(x,y)
merge(x,y,all.x=TRUE)
dplyr::left_join(x,y)

QuantAndrew/QUtility documentation built on May 14, 2019, 7:36 a.m.