Re: [R] replace values in vector from a replacement table

2012-07-31 Thread Liviu Andronic
On Mon, Jul 30, 2012 at 6:00 PM, jim holtman wrote: > try this: > >> (x <- rep(letters,2)) > [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" > "q" "r" "s" "t" "u" "v" "w" > [24] "x" "y" "z" "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" > "n" "o" "p" "q" "r" "s" "t" > [47

Re: [R] replace values in vector from a replacement table

2012-07-30 Thread Liviu Andronic
On Mon, Jul 30, 2012 at 6:00 PM, jim holtman wrote: > try this: >> indx <- match(x, repl.tab[, 1], nomatch = 0) >> x[indx != 0] <- repl.tab[indx, 2] >> x > [1] "A" "B" "c" "D" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" > "q" "r" "s" "t" "u" "v" "w" > [24] "x" "y" "z" "A" "B" "c" "D" "e" "f"

Re: [R] replace values in vector from a replacement table

2012-07-30 Thread jim holtman
try this: > (x <- rep(letters,2)) [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" "t" "u" "v" "w" [24] "x" "y" "z" "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" "t" [47] "u" "v" "w" "x" "y" "z" > values <- c("aa", "a", "b", NA, "d", "z