View source: R/merge_duplicate.R
merge_duplicate | R Documentation |
This function merges two data frames by resolving duplicated column names based on user preference. It provides options to choose which data frame's duplicated columns to keep, ensuring smooth merges without losing important data integrity.
merge_duplicate(x, y, by.x, by.y, all.x, all.y, all = NULL, choose = "x")
x |
The first data frame to be merged. |
y |
The second data frame to be merged. |
by.x |
The column name(s) in 'x' used for merging. |
by.y |
The column name(s) in 'y' used for merging. |
all.x |
Logical indicating if all rows from 'x' should be included in the output. |
all.y |
Logical indicating if all rows from 'y' should be included in the output. |
all |
Logical indicating if all rows from both 'x' and 'y' should be included in the output, superseding 'all.x' and 'all.y' if not NULL. |
choose |
Specifies which data frame's duplicated non-joining columns should be retained: "x" or "y". |
A data frame resulting from merging 'x' and 'y' according to the specified parameters.
df1 <- data.frame(ID = 1:3, Name = c("A", "B", "C"), Value = 1:3)
df2 <- data.frame(ID = 1:3, Name = c("X", "Y", "Z"), Score = 4:6)
merged_df <- merge_duplicate(df1, df2, by.x = "ID", by.y = "ID", all.x = TRUE, all.y = FALSE, choose = "x")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.