[R] [PS] vlookup in R
Ben Fairbank
BEN at SSANET.COM
Mon Mar 24 16:12:43 CET 2008
Another way:
If x is a two column matrix, as suggested by Henrique D.,
ID Value
1 7 0.000656733
2 6 0.201764789
3 1 0.671113391
4 10 -0.739727826
5 9 -1.111310154
6 5 -0.859455833
7 2 -1.408229877
8 8 0.993126295
9 3 -0.171906808
10 4 -0.140107677
And you are looking up the value corresponding to "ID"
ID <- 4
x[(1:dim(x)[1])[x[,1]==ID],2]
will also do it, and you can vary the value of the 2 in order to query
the column of interest, much as you can do with vlookup in the E
program.
Ben
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On Behalf Of Sachin J
Sent: Monday, March 24, 2008 9:25 AM
To: r-help at r-project.org
Subject: [PS] [R] vlookup in R
Hi,
Is there are function similar to excel vlookup in R. Please let me know.
Thanks,
Sachin
More information about the R-help
mailing list