I have a huge string in R where I want to remove single characters from. So for example, the string might be
blabla a test this that b á
And the result should be
blabla test this that
How do I do this in R?
Data Science Stack Exchange is a question and answer site for Data science professionals, Machine Learning specialists, and those interested in learning more about the field. It only takes a minute to sign up.Sign up to join this community
This splits the string and filters the substrings by length, no regex:
string <- "blabla a test this that b á" paste(Filter(function(x) nchar(x) > 1, unlist(strsplit(string, " "))), collapse=" ") #  "blabla test this that"
(does not work with multiple space characters)