Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kwstat/lookup
Functions Similar to VLOOKUP in Excel
https://github.com/kwstat/lookup
Last synced: about 1 month ago
JSON representation
Functions Similar to VLOOKUP in Excel
- Host: GitHub
- URL: https://github.com/kwstat/lookup
- Owner: kwstat
- License: other
- Created: 2021-04-12T16:03:36.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-07-17T12:13:53.000Z (5 months ago)
- Last Synced: 2024-10-13T15:42:38.185Z (about 2 months ago)
- Language: R
- Homepage: https://kwstat.github.io/lookup/
- Size: 1.16 MB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: NEWS.md
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - kwstat/lookup - Functions Similar to VLOOKUP in Excel (R)
README
# lookup
[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/lookup)](https://cran.r-project.org/package=lookup)
[![CRAN_Downloads](https://cranlogs.r-pkg.org/badges/lookup)](https://cranlogs.r-pkg.org/badges/lookup)Homepage: https://kwstat.github.io/lookup
Repository: https://github.com/kwstat/lookup
## Key features
The `merge()` function works great to combine dataframes. Until it returns more rows than expected. Or more columns than expected. Or more rows and columns than expected. The `match()` function can be used, but it is convoluted.
This package provides two simple functions:
* `vlookup()` is similar to Excel's `VLOOKUP`
* `lookup(x,key,value)` is a more sequential-thinking version of `match()`. Look for `x` in `key` and return the same position element from `value`.Both functions return a vector that is the same length as the input.
## Installation
```R
# Install the released version from CRAN:
install.packages("lookup")# Install the development version from GitHub:
install.packages("devtools")
devtools::install_github("kwstat/lookup")
```## Usage
```R
library(lookup)dat = as.data.frame(state.x77)
dat$statename = rownames(dat)lookup(state.name[1:5], dat$statename, dat$Frost)
# [1] 20 152 15 65 20vlookup(state.name[1:5], dat, "statename", "Frost")
# [1] 20 152 15 65 20```