[R] table lookup n R

Gabor Grothendieck ggrothendieck at myway.com
Tue Jul 13 15:05:20 CEST 2004


Try subscripting, e.g.

   # L holds numbers; its names hold lookup keys
   L <- 1:26; names(L) <- letters
   L[c("d","f")]  # look up numbers of d and f

or merge, e.g.

   merge(c("d","f"), L, by.x = 1, by.y = 0)


Anne <anne.piotet <at> urbanet.ch> writes:

: 
: Hello R helpers!
: I looked  but did not find a table-lookup R-utility. I could use a loop to 
do the job (old FORTRAN/C habits die
: hard) but if I have a big table in which I have to search for the values 
corresponding to a vector, I end up
: logically with a double loop.
: Is there already such a utility? Otherwise, is there a way without loops?
: 
: Thanks as always
: Anne




More information about the R-help mailing list