I've read some nice question about splitting uppercases and lowercases, like this, and this, but I cannot manage to make them work with my data.
# here my data
data <- data.frame(text = c("SOME UPPERCASES And some Lower Cases"
,"OTHER UPPER CASES And other words"
, "Some lower cases AND UPPER CASES"
,"ONLY UPPER CASES"
,"Only lower cases, maybe"
,"UPPER lower UPPER!"))
data
text
1 SOME UPPERCASES And some Lower Cases
2 OTHER UPPER CASES And other words
3 Some lower cases AND UPPER CASES
4 ONLY UPPER CASES
5 Only lower cases, maybe
6 UPPER lower UPPER!
The desired result should be something like this:
V1 V2
1 SOME UPPERCASES And some Lower Cases
2 OTHER UPPER CASES And other words
3 AND UPPER CASES Some lower cases
4 ONLY UPPER CASES NA
5 NA Only lower cases, maybe
6 UPPER UPPER! lower
So separate all the words with uppercases only letters, from the others.
As test, I've tried only for one line some ways but none of them work well:
strsplit(x= data$text[1], split="[[:upper:]]") # error
gsub('([[:upper:]])', ' \\1', data$text[1]) # not good results
library(reshape)
transform(data, FOO = colsplit(data$text[1], split = "[[:upper:]]", names = c('a', 'b'))) # neither good results