Error in rbind(deparse.level, …) : numbers of columns of arguments do not match R

Find the common columns:

common_cols <- intersect(colnames(train), colnames(test))

Now perform the rbind

train_test=rbind(subset(train, select = common_cols), 
  subset(test, select = common_cols))

Leave a Comment