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
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"
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
Dear all
I've got stuck when trying to replace values in a vector by selecting
replacements from a replacement table. I'm trying to use only base
functions. Here's a dummy example:
> (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"
[
4 matches
Mail list logo