| col_concat | R Documentation |
This function will return a vector, with the same length as the number of rows of the provided data frame. Each element of the vector will be it's corresponding row with all of its values (one for each column) "pasted" together in a string.
col_concat(data, sep = ", ")
data |
A data frame |
sep |
A string to separate the columns with (default: ", ") |
Rows that differ can still give the same string if the
separator also appears inside the values (for example "a, b"
and "c" against "a" and "b, c"). To check that
columns are jointly unique without building strings, use
verify(is_uniq(col1, col2))
A vector of rows concatenated into strings
paste
col_concat(mtcars)
library(magrittr) # for piping operator
# you can use "assert_rows", "is_uniq", and this function to
# check if joint duplicates (across different columns) appear
# in a data frame
## Not run:
mtcars %>%
assert_rows(col_concat, is_uniq, mpg, hp)
# fails because the first two rows are jointly duplicates
# on these two columns
## End(Not run)
mtcars %>%
assert_rows(col_concat, is_uniq, mpg, hp, wt) # ok
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.