merge 함수

R의 data.table로 데이터 결합하기

Scott Ritchie

Postdoctoral Researcher in Systems Genomics

조인

  • 조인 개념은 데이터베이스 쿼리 언어(예: SQL)에서 유래합니다.

  • 네 가지 표준 조인:

    • inner
    • full
    • left
    • right
  • 네 가지 모두 merge()로 수행할 수 있습니다.

R의 data.table로 데이터 결합하기

Inner 조인

data.table 모두에 정보가 있는 관측값만 유지합니다.

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

R의 data.table로 데이터 결합하기

by 인수

동일한 열 이름 반복 입력을 피하려면 by를 사용하십시오.

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

R의 data.table로 데이터 결합하기

Full 조인

어느 한 data.table에라도 있는 모든 관측값을 유지합니다.

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

R의 data.table로 데이터 결합하기

연습해 봅시다!

R의 data.table로 데이터 결합하기

Preparing Video For Download...