Vectorized over string.

str_split_camel_case(string, lower = FALSE)

Arguments

string

A character vector.

lower

Do you want the output to be all lower case (or as is)?

Value

A list of character vectors, one list element for each element of string.

References

Adapted from Ramnath Vaidyanathan's answer at http://stackoverflow.com/questions/8406974/splitting-camelcase-in-r.

See also

Other splitters: str_split_by_numbers()

Examples

str_split_camel_case(c("RoryNolan", "NaomiFlagg", "DepartmentOfSillyHats"))
#> [[1]]
#> [1] "Rory"  "Nolan"
#> 
#> [[2]]
#> [1] "Naomi" "Flagg"
#> 
#> [[3]]
#> [1] "Department" "Of"         "Silly"      "Hats"      
#> 
str_split_camel_case(c("RoryNolan", "NaomiFlagg", "DepartmentOfSillyHats",
  lower = TRUE
))
#> [[1]]
#> [1] "Rory"  "Nolan"
#> 
#> [[2]]
#> [1] "Naomi" "Flagg"
#> 
#> [[3]]
#> [1] "Department" "Of"         "Silly"      "Hats"      
#> 
#> [[4]]
#> [1] "T" "R" "U" "E"
#>