Vítejte v kurzu

Joining Data with data.table in R

Scott Ritchie

Postdoctoral Researcher in Systems Genomics

Spojování data.tables

  • Sloučení informací ze dvou data.tables do jedné data.table

Joining Data with data.table in R

Přehled kurzu

  • Kapitola 1: Spojování dat pomocí merge()

  • Kapitola 2: Spojování v pracovním postupu data.table

  • Kapitola 3: Řešení problémů se spojováním

  • Kapitola 4: Zřetězení a přetváření data.tables

Joining Data with data.table in R

Klíče tabulek

Sloupce propojující informace mezi dvěma tabulkami

library(data.table)

demographics <- data.table(name = c("Trey", "Matthew", "Angela"), gender = c(NA, "M", "F"), age = c(54, 43, 39)) shipping <- data.table(name = c("Matthew", "Trey", "Angela"), address = c("7 Mill road", "12 High street", "33 Pacific boulevard"))

Joining Data with data.table in R

Prohlížení `data.tables` v relaci R

Funkce tables() zobrazí všechny data.tables načtené v relaci R

tables()
           NAME NROW NCOL MB            COLS KEY
1: demographics    3    3  0 name,gender,age    
2:     shipping    3    2  0    name,address    
Total: 0MB
Joining Data with data.table in R

Prohlížení `data.tables` v relaci R

str() zobrazí typ každého sloupce v daném data.table

str(demographics)
Classes 'data.table' and 'data.frame':    3 obs. of  3 variables:
 $ name  : chr  "Trey" "Matthew" "Angela"
 $ gender: chr  NA "M" "F"
 $ age   : num  54 43 39
 - attr(*, ".internal.selfref")=<externalptr> 
Joining Data with data.table in R

Prohlížení `data.tables` v relaci R

demographics_all
         name sex age
  1:     Trey  NA  54
  2:  Matthew   M  43
  3:   Angela   F  39
  4: Michelle   F  63
  5:  Mohamed   M  26
 ---                 
102:  Patrick   M  27
103:      Wei   F  41
104:     Adam   M  33
105:  Somchai   M  53
106:     Alma   F  19
Joining Data with data.table in R

Pojďme si procvičit!

Joining Data with data.table in R

Preparing Video For Download...