hadley/plyr — pull request #75 by wch (2012-02-09 03:24:49+00:00)
Title: replace_values function

This adds a function to replace values in a factor or character vector with new values. Examples:

```R
x <- c("a", "b", "c")
replace_values(x, c("a" = "A", "c" = "C"))
# [1] "A" "b" "C"

y <- factor(c("a", "b", "c", "a"))
replace_values(y, c(a = "A", c = "C"))
# [1] A b C A
# Levels: A b C
```

It's called in a manner similar to the `rename` function. One drawback to doing it this way, with named values, is that it won't work with numeric vectors. It could be done, but it would be a bit ugly, with a conversion to character vector in the middle. Also, this might be unpredictable for floating point values.