두 개의 dataframe 비교

Published onesixx on

https://stackoverflow.com/questions/10592148/compare-if-two-dataframe-objects-in-r-are-equal

 

a <- data.frame(x = 1:10)
b <- data.frame(x = 1:10)

all(a==b)         # TRUE
identical(a,b)    # TRUE

 

## 컬럼명이 같아야 함
a <- data.frame(x = 1:10)
b <- data.frame(y = 1:10)

all(a==b)                       # TRUE
identical(a,b)                  # FALSE
identical(a[ ,"x"], b[ ,"y"])   # TRUE

 

## Class가 같아야 함
a <- data.frame(x = 1:10)
b <- tbl_df(a)

all(a==b)         # TRUE
identical(a,b)    # FALSE

 

 

 

 

Categories: Reshaping

onesixx

Blog Owner

Leave a Reply

Your email address will not be published.