[R] Translation of the charter

Greg Minshall m|n@h@|| @end|ng |rom um|ch@edu
Tue Nov 2 08:57:15 CET 2021


Heinz,

> x <- c("a","b","c")
> lettersnum <- 1:length(letters[])
> names(lettersnum) <- letters[]
> lettersnum[x]
> > lettersnum[x]
> a b c
> 1 2 3

i'm not sure if the following is obviously better, but one might do
----
> b <- match(a, a)
> names(b) <- a
> b
a b c
1 2 3
----

cheers, Greg



More information about the R-help mailing list