Hi, I search a way to replace multiple occurrences of a string with different strings depending on the place where it occurs.
I tried the following; x <- c("xx y e d xx e t f xx e f xx") x <- gsub("xx", c("x1", "x2", "x3", "x4"), x) what I want to get is; x = x1 y y e d x2 e t f x3 e f x4 but what I get is; x = x1 y y e d x1 e t f x1 e f x1 [[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.