## Combining dataframes when the columns don’t match
#' @title Combining dataframes when the columns don’t match
#' @param input1 first data frame
#' @param input2 2nd data frame
#' @export
#' @examples
#' rbind.match.columns(database.one, database.two)
#' https://amywhiteheadresearch.wordpress.com/2013/05/13/combining-dataframes-when-the-columns-dont-match/
rbind.match.columns <- function(input1, input2) {
n.input1 <- ncol(input1)
n.input2 <- ncol(input2)
if (n.input2 < n.input1) {
TF.names <- which(names(input2) %in% names(input1))
column.names <- names(input2[, TF.names])
} else {
TF.names <- which(names(input1) %in% names(input2))
column.names <- names(input1[, TF.names])
}
return(rbind(input1[, column.names], input2[, column.names]))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.