Skip to content

Instantly share code, notes, and snippets.

@PhillRob
Last active August 29, 2015 14:24
Show Gist options
  • Save PhillRob/187ffd624576ed9e0d6d to your computer and use it in GitHub Desktop.
Save PhillRob/187ffd624576ed9e0d6d to your computer and use it in GitHub Desktop.
rbind data frames with miss matching columns
rbind.keep.columns <- function(x, y) {
x.dif <- setdiff(colnames(x), colnames(y))
y.dif <- setdiff(colnames(y), colnames(x))
x[, c(as.character(y.dif))] <- NA
y[, c(as.character(x.dif))] <- NA
return(rbind(x, y))
}
@PhillRob
Copy link
Author

PhillRob commented Jul 2, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment