unite_str {tidyplus} | R Documentation |
Unite multiple character columns into one
Description
Convenience function for combining character columns.
Usage
unite_str(data, col, ..., sep = ". ", remove = TRUE)
Arguments
data |
A data frame. |
col |
The name of the new column, as a string or symbol. This argument is passed by expression and supports
quasiquotation (you can unquote strings
and symbols). The name is captured from the expression with
|
... |
< |
sep |
Separator to use between values. |
remove |
If |
Details
Blank values of "" are converted into missing values.
Value
The original data frame with the one or more columns combined as character vectors separated by a period.
See Also
tidyr::unite()
and collapse_comments()
Examples
data <- tibble::tibble(x = c("good", "Saw fish.", "", NA), y = c("2021", NA, NA, NA))
# unite has poor handling of character vectors
tidyr::unite(data, "new", x, y, remove = FALSE)
unite_str(data, "new", x, y, remove = FALSE)