Skip to content
/ lookup Public

Functions Similar to VLOOKUP in Excel

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
Notifications You must be signed in to change notification settings

kwstat/lookup

Repository files navigation

lookup

CRAN_Status_Badge CRAN_Downloads

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

# Install the released version from CRAN:
install.packages("lookup")

# Install the development version from GitHub:
install.packages("devtools")
devtools::install_github("kwstat/lookup")

Usage

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  20

vlookup(state.name[1:5], dat, "statename", "Frost")
#  [1]  20 152  15  65  20

About

Functions Similar to VLOOKUP in Excel

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages