VLOOKUP: Basic VLOOKUP function from excel

Description Usage Arguments Value Examples

View source: R/VLOOKUP.R

Description

It acts similiarly to Excel's VLOOKUP function with some extra arguments. It takes the value that you want to take from another table and returns the corresponding value from another table. Basically it's an SQL Left Join.

Usage

1
2
3
4
5
6
7
VLOOKUP(
  lookup_from_table,
  lookup_column_value = "Name of the column to lookup",
  lookup_where_table,
  lookup_where_table_column = "Name of the column to compare",
  return_which_column = "Name of the column to return"
)

Arguments

lookup_from_table

The table it should lookup values from

lookup_column_value

which column should be looked up

lookup_where_table

which table should it look for the values in

lookup_where_table_column

Which column should it look for the values in.

return_which_column

Which column should it return

Value

In this case we have built-in database Sales and Street. We try to merge these 2 tables to see on which street are the salesman based on their countries. Function can return numeric,character,logical or any other class, it depends on what is in the table you are looking up the value in.

Examples

1
VLOOKUP(Sales,"Country",Streets,"Country","Street")

Example output

      Names Country Cost Sales              Street
16   Irakli Georgia    4     6              Pekini
12   Sandro England    3     9                <NA>
22     Nika     USA    3     7          Wallstreet
1      Avto America    1     6                <NA>
2     Shako  Brazil    1    10 Rua Farme de Amoedo
8  Bechvaia    Cuba    5    10                <NA>
7    Sandro    Cuba    2     6                <NA>
10   Sandro    Cuba    1     6                <NA>
6    Sandro    Cuba    5     5                <NA>
18    Shako Georgia    4     5              Pekini
17    Shako Georgia    2     6              Pekini
20    Shako Georgia    4     7              Pekini
21 Bechvaia     USA    2     8          Wallstreet
24 Bechvaia     USA    1     9          Wallstreet
23 Bechvaia     USA    1    10          Wallstreet
15 Bechvaia England    1     5                <NA>
13   Sandro England    2    10                <NA>
14   Sandro England    2     7                <NA>
4    Sandro  Brazil    4    10 Rua Farme de Amoedo
5      Avto  Brazil    4     5 Rua Farme de Amoedo
3      Avto  Brazil    5    10 Rua Farme de Amoedo
19     Avto Georgia    3     6              Pekini
9      Avto    Cuba    4     9                <NA>
11   Irakli    Cuba    2     5                <NA>

ExcelFunctionsR documentation built on July 1, 2020, 8:35 p.m.