merge_with_precedence: Merge two 'data.frame's, but where there are common fields...

Description Usage Arguments Value See Also Examples

View source: R/utils.R

Description

Merge two data.frames, but where there are common fields those in x are retained and those in y are dropped.

Usage

1
merge_with_precedence(x, y, by, allow.cartesian = TRUE, as_data_frame = TRUE)

Arguments

x

the data.frame whose columns take precedence

y

another data.frame

by

a vector of column names to merge on

allow.cartesian

boolean indicating whether it's ok for repeated values in either table to merge with each other over and over again.

as_data_frame

boolean indicating whether to ensure the returned object is a data.frame instead of a data.table. This ensures compatibility with GCT object conventions, that is, the rdesc and cdesc slots must be strictly data.frame objects.

Value

a data.frame or data.table object

See Also

data.table::merge

Examples

1
2
3
4
5
(x <- data.table::data.table(foo=letters[1:10], bar=1:10))
(y <- data.table::data.table(foo=letters[1:10], bar=11:20,
  baz=LETTERS[1:10]))
# the 'bar' column from y will be dropped on merge
cmapR:::merge_with_precedence(x, y, by="foo")

cmap/cmapR documentation built on Oct. 14, 2021, 12:51 a.m.