[R] HLOOKUP in R
jrkrideau at inbox.com
Mon Jul 16 18:04:55 CEST 2012
My understanding of HVLOOKUP, based on a through 30 second reading of some on-line documenation is that tht it sets up a grid "table?) of values and if one feeds it the value in the first horizontal vector and a row number it returns the value in that row.
so if df1[,10] == 15 and you want the value in the second row of the table you would feed in Hvlookput(15, 2) and would return the value in df1[2, 10]
Of course the values in df[1,] must be unique
One could put something lile this into a function to get what the op wants, I think
mda <- data.frame(rbind(hlp <- 1:10, targ <- c(11:20)))
xx <- 4
hvlook <- mda[2 , match(1, df1[, xx]) ]
Kingston ON Canada
> -----Original Message-----
> From: santosh.srinivas at gmail.com
> Sent: Sun, 15 Jul 2012 04:56:30 -0700 (PDT)
> To: r-help-archive at googlegroups.com
> Subject: Re: [R] HLOOKUP in R
> Try ?match
> Adapt it to your need
> On Saturday, July 14, 2012 12:55:33 AM UTC+5:30, Silje Nord wrote:
>> Is there a function similar to excel's hlookup in R ?
>> R-help at r-project.org mailing list
>> PLEASE do read the posting guide
>> and provide commented, minimal, self-contained, reproducible code.
> R-help at r-project.org mailing list
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.
FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!
More information about the R-help