Hi,
May be this helps: chnew<-CH chnew[duplicated(toupper(CH))]<-CH[duplicated(toupper(CH),fromLast=TRUE)] chnew #[1] "aBd" "sTb" "aBd" "dFDasd" "asd" "dFDasd" A.K. ----- Original Message ----- From: Christofer Bogaso <bogaso.christo...@gmail.com> To: r-help <r-help@r-project.org> Cc: Sent: Sunday, August 11, 2013 8:39 AM Subject: [R] Working with string Hello again, Let say I have a lengthy character vector like: CH <- c("aBd", "sTb", "ABD", "dFDasd", "asd", "DFDASD") Now I want to create a vector like: CH_New <- c("aBd", "sTb", "aBd", "dFDasd", "asd", "dFDasd") ## the 3rd and 6th element replaced Basically, the goal is: If an element has all upper case then it will find another element with all lower case or mix of upper/lower case. Then the all-upper-case element will be replaced by that mix. If there is multiple match then chose the first one. Can somebody give me any pointer how can I achieve that? Thanks and regards, [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.