vlookup: vlookup In R Using 'merge()'

View source: R/vlookup.R

vlookupR Documentation

vlookup In R Using merge()

Description

Implementing vlookup in R using merge().

Usage

vlookup(data, lookup_table, data_col, lookup_col, lookup_value)

Arguments

data

Dataframe to vlookup from.

lookup_table

Table to lookup from, contains an identifier and a value column.

data_col

String. The column from data that contains the identifier.

lookup_col

String. The column from lookup_table that contains the identifier.

lookup_value

String. The column from lookup_table that contains the value.

Examples

mydata <- data.frame(Type = rep(1:3,5), Rand = 4:6)
mytable <- data.frame(Type = 1:3, Magnitude = c("Low","Medium","High"))
vlookup(data = mydata,
        lookup_table = mytable,
        data_col = "Type",
        lookup_col = "Type",
        lookup_value = "Magnitude")

Aaron0696/aaRon documentation built on July 27, 2023, 2:05 p.m.