Left e right join

Unire i dati con data.table in R

Scott Ritchie

Postdoctoral Researcher in Systems Genomics

Left join

Aggiungi informazioni dal data.table di destra al data.table di sinistra

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

Unire i dati con data.table in R

Right join

Aggiungi informazioni dal data.table di sinistra al data.table di destra

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

Unire i dati con data.table in R

Right join - Left join

# Right join
merge(x = demographics, y = shipping, by = "name", all.y = TRUE)

# Uguale a
merge(x = shipping, y = demographics, by = "name", all.x = TRUE)
Unire i dati con data.table in R

Valori predefiniti

  • I valori predefiniti di all, all.x e all.y sono FALSE nella funzione merge()

  • Controlla i valori predefiniti degli argomenti con help("merge")

Unire i dati con data.table in R

Istruzioni dell'esercizio

Esegui un left join di shipping con demographics:

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

Esegui un right join di shipping con demographics:

merge(demographics, shipping, by = "name", all.y = TRUE)
Unire i dati con data.table in R

Esercitiamoci!

Unire i dati con data.table in R

Preparing Video For Download...