assertr (version 3.0.1)

col_concat: Concatenate all columns of each row in data frame into a string

Description

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.

Usage

col_concat(data, sep = "")

Value

A vector of rows concatenated into strings

Arguments

data

A data frame

sep

A string to separate the columns with (default: "")

See Also

Examples

Run this code

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
if (FALSE) {
mtcars %>%
  assert_rows(col_concat, is_uniq, mpg, hp)
  # fails because the first two rows are jointly duplicates
  # on these two columns
}

mtcars %>%
  assert_rows(col_concat, is_uniq, mpg, hp, wt) # ok

Run the code above in your browser using DataLab