课程: R for Data Science: Lunch Break Lessons

免费学习该课程!

今天就开通帐号,24,100 门业界名师课程任您挑!

Excel in R: LOOKUP

Excel in R: LOOKUP

- [Instructor] We're talking about Excel functions and how to duplicate them in R. This week let's talk about LOOKUP. I've created a spreadsheet here with a lookup value from cell A10, and the formula is LOOKUP, then a parentheses and a 5, and 5 is the value that we're searching for. Then it says A1 through A8, and this is the range that you're searching in, which is actually the first column. And then it also says B1 through B6, which is where I want to return a value from. So what I've said is, look in the first range, A1 through A6, find any values equal to 5 and return the corresponding value from B. So you'll see that B4 is equal to 8, and that corresponds to A4. Now, how do you do that in R? So we're looking at R code now in RStudio. The first thing you should know is that I've already imported Spreadsheet. Line 13 is where I use as.data.frame and read_Excel to bring in the SampleSpreadsheet file into a…

内容