meld | R Documentation |
This function simplifies the process of merging multiple cleaned data frames by automatically determining common merge keys or utilizing user-specified keys. Supports both inner and outer join methods, and offers options for exporting the merged data.
meld(
...,
by = NULL,
all = TRUE,
no.dups = FALSE,
csv = FALSE,
rdata = FALSE,
spss = FALSE
)
... |
Clean data frames to be merged. |
by |
A vector of strings specifying the column names to be used as merge keys. If NULL, the function automatically determines common keys from the provided data frames. |
all |
Logical; if TRUE, performs an OUTER JOIN. If FALSE, performs an INNER JOIN. |
no.dups |
Logical; if TRUE, duplicates are removed post-merge. |
csv |
Logical; if TRUE, the merged data frame is exported as a CSV file. |
rdata |
Logical; if TRUE, the merged data frame is saved as an Rda file. |
spss |
Logical; if TRUE, the merged data frame is exported as an SPSS file. |
A merged data frame based on the specified or common candidate keys.
Joshua Kenney joshua.kenney@yale.edu
## Not run:
# Create sample dataframes for demonstration
df1 <- data.frame(
src_subject_id = c("S001", "S002", "S003"),
visit = c(1, 2, 1),
measure1 = c(10, 15, 12),
stringsAsFactors = FALSE
)
df2 <- data.frame(
src_subject_id = c("S001", "S002", "S004"),
visit = c(1, 2, 2),
measure2 = c(85, 92, 78),
stringsAsFactors = FALSE
)
# Perform an OUTER JOIN using default keys:
merged1 <- meld(df1, df2, all = TRUE)
# Perform an INNER JOIN using specified keys:
merged2 <- meld(df1, df2, by = "src_subject_id", all = FALSE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.