Separate column into multiple columns
split_cols.Rd
Separate column into multiple columns
Arguments
- data
data.frame
ortibble
- col
column to separate
- pattern
regular expression pattern passed to
strsplit()
- col_prefix
prefix for new columns
Examples
d <- data.frame(value = c(29L, 91L, 39L, 28L, 12L),
name = c("John", "John, Jacob",
"John, Jacob, Jingleheimer",
"Jingleheimer, Schmidt",
"JJJ, Schmidt"))
split_cols(data = d, col = "name", col_prefix = "names")
#> value name names_1 names_2 names_3
#> 1 29 John John <NA> <NA>
#> 2 91 John, Jacob John Jacob <NA>
#> 3 39 John, Jacob, Jingleheimer John Jacob Jingleheimer
#> 4 28 Jingleheimer, Schmidt Jingleheimer Schmidt <NA>
#> 5 12 JJJ, Schmidt JJJ Schmidt <NA>