我正在尝试拆分结构如下的字符串:
string <- c("ThisThat","OneTwo","LeftRight","RightHere")
并将其转换为:
>string
[1] "This That" "One Two" "Left Right" "Right Here"
我在&#39; stringr&#39;中尝试了很多功能。和&#39; stringi&#39;包。有什么帮助吗?
答案 0 :(得分:3)
这对你有用吗?
gsub("([A-Z])", " \\1", string) %>% trimws()
[1] "This That" "One Two" "Left Right" "Right Here"