R tips 데이터의 결합에 사용할 수 있는 join계와 bind계
10598 단어 R
기사의 목적
이 기사에서는 데이터를 결합하는 데 사용되는 함수를 소개합니다.
목차
No.
목차
설명
1
사용할 라이브러리 및 데이터
원본 데이터/dplyr
2
left_join
key를 지정하고 왼쪽 데이터를 떠나 결합
3
right_join
key를 지정하고 오른쪽 데이터를 모두 남겨 결합
4
full_join
key를 지정해, 좌우의 데이터를 모두 남겨 결합
5
rbind
그대로 세로로 결합
6
cbind
그대로 옆으로 결합
1. 사용할 라이브러리 및 데이터
library(dplyr)
Id1 <- c(1,2,3)
Height <- c(150,160,170)
Data.A <- data.frame(Id1, Height)
Id2 <- c(1,3,5)
Weight <- c(50,60,70)
Data.B <- data.frame(Id2, Weight)
Id1 <- c(4,5,6)
Height <- c(160,150,170)
Data.C <- data.frame(Id3, Height)
Data.A
Data.B
Data.C



2. left_join (key를 지정하고 왼쪽 데이터를 남겨 결합)
왼쪽 데이터는 모두 남아 있지만 Id1에 해당하지 않는 왼쪽 데이터는 포함되지 않습니다.
left_join(Data.A, Data.B, by=c("Id1"="Id2"))
Data.A
Data.B
결합 후



3. right_join (key를 지정하고 오른쪽 데이터를 남겨 결합)
오른쪽 데이터는 모두 남아 있지만 Id2에 해당하지 않는 오른쪽 데이터는 포함되지 않습니다.
right_join(Data.A, Data.B, by=c("Id1"="Id2"))
Data.A
Data.B
결합 후



4. full_join (key를 지정하고 좌우의 데이터를 남겨 결합)
full_join(Data.A, Data.B, by=c("Id1"="Id2"))
Data.A
Data.B
결합 후



5. rbind 그대로 세로로 결합
rbind(Data.A, Data.C)
Data.A
Data.C
결합 후



6. cbind 그대로 옆으로 결합
cbind(Data.A, Data.B)
Data.A
Data.B
결합 후



◯SNS
・youtube
htps : // 코 m / 찬 l / 우 CFDy ぇ ywt hdtwqC3
· Twitter
htps : // 라고 해서 r. 코 m / D 켄_타
Reference
이 문제에 관하여(R tips 데이터의 결합에 사용할 수 있는 join계와 bind계), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/Tatsuki-Oike/items/d1571fab7c3c23585d25
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
No.
목차
설명
1
사용할 라이브러리 및 데이터
원본 데이터/dplyr
2
left_join
key를 지정하고 왼쪽 데이터를 떠나 결합
3
right_join
key를 지정하고 오른쪽 데이터를 모두 남겨 결합
4
full_join
key를 지정해, 좌우의 데이터를 모두 남겨 결합
5
rbind
그대로 세로로 결합
6
cbind
그대로 옆으로 결합
1. 사용할 라이브러리 및 데이터
library(dplyr)
Id1 <- c(1,2,3)
Height <- c(150,160,170)
Data.A <- data.frame(Id1, Height)
Id2 <- c(1,3,5)
Weight <- c(50,60,70)
Data.B <- data.frame(Id2, Weight)
Id1 <- c(4,5,6)
Height <- c(160,150,170)
Data.C <- data.frame(Id3, Height)
Data.A
Data.B
Data.C



2. left_join (key를 지정하고 왼쪽 데이터를 남겨 결합)
왼쪽 데이터는 모두 남아 있지만 Id1에 해당하지 않는 왼쪽 데이터는 포함되지 않습니다.
left_join(Data.A, Data.B, by=c("Id1"="Id2"))
Data.A
Data.B
결합 후



3. right_join (key를 지정하고 오른쪽 데이터를 남겨 결합)
오른쪽 데이터는 모두 남아 있지만 Id2에 해당하지 않는 오른쪽 데이터는 포함되지 않습니다.
right_join(Data.A, Data.B, by=c("Id1"="Id2"))
Data.A
Data.B
결합 후



4. full_join (key를 지정하고 좌우의 데이터를 남겨 결합)
full_join(Data.A, Data.B, by=c("Id1"="Id2"))
Data.A
Data.B
결합 후



5. rbind 그대로 세로로 결합
rbind(Data.A, Data.C)
Data.A
Data.C
결합 후



6. cbind 그대로 옆으로 결합
cbind(Data.A, Data.B)
Data.A
Data.B
결합 후



◯SNS
・youtube
htps : // 코 m / 찬 l / 우 CFDy ぇ ywt hdtwqC3
· Twitter
htps : // 라고 해서 r. 코 m / D 켄_타
Reference
이 문제에 관하여(R tips 데이터의 결합에 사용할 수 있는 join계와 bind계), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/Tatsuki-Oike/items/d1571fab7c3c23585d25
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
library(dplyr)
Id1 <- c(1,2,3)
Height <- c(150,160,170)
Data.A <- data.frame(Id1, Height)
Id2 <- c(1,3,5)
Weight <- c(50,60,70)
Data.B <- data.frame(Id2, Weight)
Id1 <- c(4,5,6)
Height <- c(160,150,170)
Data.C <- data.frame(Id3, Height)
왼쪽 데이터는 모두 남아 있지만 Id1에 해당하지 않는 왼쪽 데이터는 포함되지 않습니다.
left_join(Data.A, Data.B, by=c("Id1"="Id2"))
Data.A
Data.B
결합 후



3. right_join (key를 지정하고 오른쪽 데이터를 남겨 결합)
오른쪽 데이터는 모두 남아 있지만 Id2에 해당하지 않는 오른쪽 데이터는 포함되지 않습니다.
right_join(Data.A, Data.B, by=c("Id1"="Id2"))
Data.A
Data.B
결합 후



4. full_join (key를 지정하고 좌우의 데이터를 남겨 결합)
full_join(Data.A, Data.B, by=c("Id1"="Id2"))
Data.A
Data.B
결합 후



5. rbind 그대로 세로로 결합
rbind(Data.A, Data.C)
Data.A
Data.C
결합 후



6. cbind 그대로 옆으로 결합
cbind(Data.A, Data.B)
Data.A
Data.B
결합 후



◯SNS
・youtube
htps : // 코 m / 찬 l / 우 CFDy ぇ ywt hdtwqC3
· Twitter
htps : // 라고 해서 r. 코 m / D 켄_타
Reference
이 문제에 관하여(R tips 데이터의 결합에 사용할 수 있는 join계와 bind계), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/Tatsuki-Oike/items/d1571fab7c3c23585d25
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
right_join(Data.A, Data.B, by=c("Id1"="Id2"))
full_join(Data.A, Data.B, by=c("Id1"="Id2"))
Data.A
Data.B
결합 후



5. rbind 그대로 세로로 결합
rbind(Data.A, Data.C)
Data.A
Data.C
결합 후



6. cbind 그대로 옆으로 결합
cbind(Data.A, Data.B)
Data.A
Data.B
결합 후



◯SNS
・youtube
htps : // 코 m / 찬 l / 우 CFDy ぇ ywt hdtwqC3
· Twitter
htps : // 라고 해서 r. 코 m / D 켄_타
Reference
이 문제에 관하여(R tips 데이터의 결합에 사용할 수 있는 join계와 bind계), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/Tatsuki-Oike/items/d1571fab7c3c23585d25
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
rbind(Data.A, Data.C)
cbind(Data.A, Data.B)
Data.A
Data.B
결합 후



◯SNS
・youtube
htps : // 코 m / 찬 l / 우 CFDy ぇ ywt hdtwqC3
htps : // 라고 해서 r. 코 m / D 켄_타
Reference
이 문제에 관하여(R tips 데이터의 결합에 사용할 수 있는 join계와 bind계), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/Tatsuki-Oike/items/d1571fab7c3c23585d25텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)