Reputation: 75
I am trying to split string that is structured like:
string <- c("ThisThat","OneTwo","LeftRight","RightHere")
and turn it into:
>string
[1] "This That" "One Two" "Left Right" "Right Here"
I have tried numerous functions in the 'stringr' and 'stringi' package. Any help?
Upvotes: 0
Views: 38
Reputation: 10671
does this work for you?
gsub("([A-Z])", " \\1", string) %>% trimws()
[1] "This That" "One Two" "Left Right" "Right Here"
Upvotes: 3