col_concat {assertr}R Documentation

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 = "")

Arguments

data

A data frame

sep

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

Value

A vector of rows concatenated into strings

See Also

paste

Examples


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


[Package assertr version 3.0.1 Index]