Hi, Is there a function similar to excel's hlookup in R ? Thanks, Silje
HLOOKUP in R
8 messages · Silje Nord, Michael Sumner, Santosh Srinivas +3 more
1 day later
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120715/17aa6d45/attachment.pl>
Try ?match Adapt it to your need
On Saturday, July 14, 2012 12:55:33 AM UTC+5:30, Silje Nord wrote:
Hi, Is there a function similar to excel's hlookup in R ? Thanks, Silje
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
On Fri, Jul 13, 2012 at 9:25 PM, Silje Nord <silje.nordgard at gmail.com> wrote:
Is there a function similar to excel's hlookup in R ?
Try match(). I think it provides hlookup() functionality. Liviu
Depending on what options of hlookup you want, 'match' will do exact matching and 'findInterval' will determine range/interval matching. What you need to do is follow the posting guide and provide an example of exactly what you data looks like and what you expect the result to be.
On Fri, Jul 13, 2012 at 3:25 PM, Silje Nord <silje.nordgard at gmail.com> wrote:
Hi, Is there a function similar to excel's hlookup in R ? Thanks, Silje
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it.
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]) ] hvlook John Kane 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:
Hi, Is there a function similar to excel's hlookup in R ? Thanks, Silje
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
____________________________________________________________ FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!
There is a "range_lookup" parameter which specifies if you want an exact match (which is what the solution below assumes), or if you want the next largest value less than the search value returned; in this case you would want to use 'findInterval'.
On Mon, Jul 16, 2012 at 12:04 PM, John Kane <jrkrideau at inbox.com> wrote:
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]) ] hvlook John Kane 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:
Hi, Is there a function similar to excel's hlookup in R ? Thanks, Silje
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
____________________________________________________________ FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop! ______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it.
My quick read of the HVLOOLUP text suggests that an exact match is what is done in Excel or other spreadsheets. But then, I've never used it. I get the impression is often used for things like price lookups. John Kane Kingston ON Canada
-----Original Message----- From: jholtman at gmail.com Sent: Mon, 16 Jul 2012 12:40:10 -0400 To: jrkrideau at inbox.com Subject: Re: [R] HLOOKUP in R There is a "range_lookup" parameter which specifies if you want an exact match (which is what the solution below assumes), or if you want the next largest value less than the search value returned; in this case you would want to use 'findInterval'. On Mon, Jul 16, 2012 at 12:04 PM, John Kane <jrkrideau at inbox.com> wrote:
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]) ] hvlook John Kane 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:
Hi, Is there a function similar to excel's hlookup in R ? Thanks, Silje
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
____________________________________________________________ FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop! ______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
-- Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it.
____________________________________________________________ FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on your desktop!