[R] String manipulation

Gang Chen gangchen6 at gmail.com
Mon Dec 8 18:08:27 CET 2014


I want to do the following: if a string does not contain a colon (:),
no change is needed; if it contains one or more colons, break the
string into multiple strings using the colon as a separator. For
example, "happy:" becomes

"happy" ":"

":sad" turns to

":" "sad"

and "happy:sad" changes to

"happy" ":" "sad"

How to do this?

Thanks,
Gang



More information about the R-help mailing list