vlookup function

Vlookup

Vlookup

Look up values in a reference data.table and return values associated with the looked-up values contained in the reference data.table

vlookup( lookup_values = NULL, reference_dt = NULL, col_name_for_lookup_values = NULL, col_name_for_output_values = NULL )

Arguments

  • lookup_values: a vector of values to look up
  • reference_dt: a data.table containing the values to look up as well as values associated with the looked-up values that need to be returned.
  • col_name_for_lookup_values: in the reference data.table, name of the column containing lookup_values.
  • col_name_for_output_values: in the reference data.table, name of the column containing values to return (i.e., values associated with the looked-up values that will be the function's output)

Examples

vlookup(lookup_values = c(2.620, 2.875), reference_dt = mtcars[1:9, ], col_name_for_lookup_values = "wt", col_name_for_output_values = "qsec")