mergeToX: merge x and y, leaving x intact

Description Usage Arguments Value Author(s) See Also Examples

View source: R/mergeToX_1.0.R

Description

merge two data frames, x and y, like merge, but x is left intact

Usage

1
2
3
4
5
6
7
8
mergeToX(
  x,
  y,
  by = intersect(names(x), names(y)),
  by.x = by,
  by.y = by,
  suffix.y = ".y"
)

Arguments

x, y

data frames to be merged, in which 'x' will not be changed at all

by

names of the columns in which the values link two data frames. When row names is used to match two tables, the function rownames can be given here.

by.x, by.y

linking column names in 'x' and 'y' if the names are different

suffix.y

the suffix for the columns in 'y' that have same name as 'x' excluding 'by.y'

Value

A merged data frame

Author(s)

Mun-Gwan Hong, mungwan@gmail.com

See Also

merge

Examples

1
2
3
4
5
tg1 <- data.frame("id"= c("s1", "s2", "s3", "s5"), "height"= c(169, 187, 175, 162))
tg2 <- data.frame("id"= c("s1", "s2", "s4", "s5"), "weight"= c(76, 89, 60, 68))
mergeToX(tg1, tg2)
rownames(tg1)
mergeToX(tg1, tg2, by= rownames)

Rundmus/Useful2me-R_package documentation built on Nov. 13, 2020, 4:16 p.m.