View source: R/data-management.R
| mergedata | R Documentation |
Merges a using data frame or file into a master data frame. Active data is used as master by default. Cardinality can be checked like Stata merges.
mergedata(
using,
by,
data = NULL,
type = c("1:1", "1:m", "m:1", "m:m"),
join = c("full", "left", "right", "inner"),
suffix = c("_master", "_using"),
generate = "_merge",
keep = NULL,
update = FALSE,
replace = FALSE,
active = TRUE,
quiet = FALSE,
labels = c("factor", "labelled", "numeric")
)
using |
Data frame or existing file path. |
by |
Key variables: bare name, |
data |
Optional explicit master data frame. |
type |
One of |
join |
One of |
suffix |
Two suffixes for overlapping non-key variables. |
generate |
Merge-status variable name, or |
keep |
Optional status codes to retain, such as |
update |
Logical; fill missing master values from using variables with the same names. |
replace |
Logical; with |
active |
Logical; replace active data with the result. |
quiet |
Logical; suppress messages. |
labels |
Label handling when |
The merged data frame invisibly.
master <- data.frame(id = 1:3, age = c(20, 30, 40))
using <- data.frame(id = 2:4, sex = c("F", "M", "F"))
usedf(master, quiet = TRUE)
mergedata(using, by = id, type = "1:1", quiet = TRUE)
result <- usedf(quiet = TRUE)
result2 <- mergedata(using, data = master, by = id, type = "1:1",
active = FALSE, quiet = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.