Question :
How do I replace a series of blanks with just one, in R?
For example, suppose we have a string:
x <- " non non non non"
I want to make the content of x be “non non non non”.
Answer :
Two possible solutions:
gsub("s+", " ", x)
and
gsub("[[:space:]]+", " ", x)