The merge function

R'de data.table ile Veri Birleştirme

Scott Ritchie

Postdoctoral Researcher in Systems Genomics

Joins

  • Concept of joins come from database query languages (e.g. SQL).

  • Four standard joins:

    • inner
    • full
    • left
    • right
  • All four can be done using merge()

R'de data.table ile Veri Birleştirme

Inner join

Only keep observations that have information in both data.tables

merge(x = demographics, y = shipping, 
      by.x = "name", by.y = "name")

R'de data.table ile Veri Birleştirme

The by argument

Use by to avoid repeated typing of the same column name

merge(x = demographics, y = shipping, 
      by = "name")

R'de data.table ile Veri Birleştirme

Full join

Keep all observations that are in either data.table

merge(x = demographics, y = shipping, 
      by = "name", all = TRUE)

R'de data.table ile Veri Birleştirme

Let's practice!

R'de data.table ile Veri Birleştirme

Preparing Video For Download...