Replacement of multiple contents of vector in R
Somethimes we need to replace multiple contents of vector in R , like I want to replace a to c and b to d in x vector . Obviously you can use gsub to finish it by two times : gsub (a , c , x ) ; gsub (b , d , x ) . Actually, we can do it in a more readable way .
> library(plyr) > x <- c("a", "b", "f") > mapvalues(x, c("a", "b"),c("c", "d"))  "c" "d" "f"
Here the old names were changed into new names at one time .
The manual of mapvalues function