Home > OS >  How to check if there are columns in one table that are not in the other in R?
How to check if there are columns in one table that are not in the other in R?

Time:02-15

I have two datasets, one with 71 columns and one with 12 columns. Each dataset has columns, which are not columns in the other dataset. How can I automatically create a list of the columns, which are part of dataset 1, but are not part of dataset 2 and vice versa?

Thanks!

CodePudding user response:

setdiff(colnames(df1), colnames(df2))

and

setdiff(colnames(df2), colnames(df1))
  •  Tags:  
  • r
  • Related