Re: [R] table lookup n R

From: Gabor Grothendieck <ggrothendieck_at_myway.com>
Date: Tue 13 Jul 2004 - 23:05:20 EST

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



R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue Jul 13 23:13:29 2004

This archive was generated by hypermail 2.1.8 : Wed 03 Nov 2004 - 22:54:54 EST