How can I change a full text to lowercase but retain the acronyms in uppercase using R? I need it for text mining and using udpi package. I could ofcourse use uppercase, but anyway to retain the uppercase acronyms while using lowercase?
tolower('NASA IS A US COMPANY').
tolower('NASA IS A US COMPANY')
tolower('NASA IS A US COMPANY')
Expected: NASA is a US company
Actual: nasa is a us company
We can do: test is the input:
paste(lapply(strsplit(test," "),function(x) ifelse(x %in% toupper(tm::stopwords()),
tolower(x),x))[[1]],collapse=" ")
[1] "NASA is a US COMPANY"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With