| left_join_x | R Documentation |
<dplyr::left_join> wrapper for xpose_data (and, by inheritance,
xp_xtras) objects. Unlike a plain left_join(), a column present in
both x and y (other than the join keys) is not duplicated with
.x/.y suffixes: missing (NA) values already in x are backfilled
from the matching value in y, while non-missing values already in x
are left untouched. This makes it straightforward to backfill a variable
(or set of variables) that is only partially recorded, from a second data
source keyed on the same join variable(s) (e.g. ID).
left_join_x() accepts xpose_data/xp_xtras objects directly, with an
additional .problem argument restricting which problem(s) the join is
applied to.
left_join() without _x is defined as an S3 method on xpose_data, so
that the usual <dplyr::left_join> generic dispatches here
automatically (xp_xtras objects are handled the same way, via class
inheritance).
left_join_x(
x,
y,
by = NULL,
copy = FALSE,
suffix = c(".x", ".y"),
...,
keep = NULL,
.problem = NULL
)
## S3 method for class 'xpose_data'
left_join(
x,
y,
by = NULL,
copy = FALSE,
suffix = c(".x", ".y"),
...,
keep = NULL,
.problem = NULL
)
x |
An |
y |
A data frame (or another object coercible to one) to join in. |
by |
Join specification, as in < |
copy |
If |
suffix |
Suffixes used internally to disambiguate a column shared by |
... |
Other parameters passed onto < |
keep |
Passed to < |
.problem |
The problem number(s) to which the join will be applied. Uses all problems if |
An updated xpose_data/xp_xtras object.
# Some subjects are missing an APGR score in the base dataset
xpdb_missing <- pheno_base %>%
mutate_x(APGR = dplyr::if_else(ID %in% c("1", "2"), NA, APGR))
# A separate table with the (complete) values, keyed on ID
apgr_lookup <- xpose::get_data(pheno_base, quiet = TRUE) %>%
dplyr::distinct(ID, APGR)
# Existing APGR values are kept; only the missing ones are filled in
left_join_x(xpdb_missing, apgr_lookup, by = "ID")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.