mergeDups | R Documentation |
Merge duplicated lines into one entry according to one or some identifier(s). Note: this function may be quite slow when input data is large.
mergeDups(x, id = 1, sep = NULL)
x |
a data frame or tibble |
id |
column index of identical variable, which is used to detect duplication, default the first column. |
sep |
separator. If column(s) to merge only contain(s) numeric values, they can be merged with the default |
Yujie Liu
x <-
data.frame(
x1 = c("A", "A", "B", "A", "C", "B"),
x2 = c(1, 1, 2, 1, 3, 2),
x3 = c(100, 100, 200, 100, 300, 200),
x4 = c(100, 200, 300, 400, 500, 600)
)
mergeDups(x, id = 1)
mergeDups(x, id = 2, sep = "+")
mergeDups(x, id = 1:3, sep = ";")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.