Hi, Here is an implementation.
> my.vector [1] "A" "B" "C" "D" "E" "F" "G" > vec1 [1] "p" "q" "r" "s" "t" > vec2 [1] "x" "y" "z" > final <- as.character(unlist(sapply(my.vector,function(x) > if(x=="B"){vec1}else{if(x=="E"){vec2}else{x}}))) > final [1] "A" "p" "q" "r" "s" "t" "C" "D" "x" "y" "z" "F" "G" -- View this message in context: http://r.789695.n4.nabble.com/Substituting-elements-in-vector-tp4703395p4703431.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.