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))
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))