I am working with strings in
. I have the next string:
x<-c("Alfa Cactus 500 Bachelor degree Star")
For example, in this string after the first word I have two spaces. After the second word I have three spaces. I am trying to replace only white spaces when there are two or more of them. In that case I would like to add
instead of white spaces. I am looking for a new string like this:
In the case of
I only have one white space. Then, the replace must not be done. When I try this:
I got this:
But, It is not respected the fact that only one white space must not be replaced. I do not know how to adapt
to perform this change.
I hope you can help me with this. Thanks a lot of.