JayAr
JayAr

Reputation: 57

How to check the variable differences between 2 df in R?

I would like to check which Cols are extra in the first DF but not visible in the second.

Do we have any function in dplyr perhaps which could help? It would be nice if this could list out the column names only which are surplus.

Upvotes: 0

Views: 98

Answers (1)

Ronak Shah
Ronak Shah

Reputation: 388982

We can use setdiff

setdiff(names(df1), names(df2))
#[1] "b" "c"

data

df1 <- data.frame(a = 1:5, b = 6:10, c = 12:16)
df2  <- data.frame(a = 11:15)

Upvotes: 2

Related Questions