I can't figure out how to write a regular expression in R that would "match" only duplicate consecutive words without space such as:
Country<-c("GhanaGhana","Bangladesh","Pakistan","Mongolia","India",
"Indonesia","UgandaUganda","ArmeniaArmenia","Sri LankaSri Lanka",
"U.S. Virgin IslandsU.S. Virgin Islands")
and transform into this:
Country<-c("Ghana","Bangladesh","Pakistan","Mongolia","India","Indonesia",
"Uganda","Armenia","Sri Lanka","U.S. Virgin Islands")
Traditional R function for this like anyDuplicated()
or unique()
is not working. Is there a way to write a regular expression for this in R?