Skip to content

Instantly share code, notes, and snippets.

@rbjanis
Last active May 27, 2021 15:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rbjanis/44dbcecb2c96c11defdb7892ad8158fb to your computer and use it in GitHub Desktop.
Save rbjanis/44dbcecb2c96c11defdb7892ad8158fb to your computer and use it in GitHub Desktop.
Compare classes of columns common to two data sets
check_column_classes <- function(dataframe1 = survey, dataframe2 = appts){
common_vars <- intersect(names(dataframe1), names(dataframe2))
dataframe2_classes <- tibble::tibble(class_dataframe2 = purrr::map_chr(dataframe2[,colnames(dataframe2) %in% common_vars], class), Column = common_vars)
dataframe1_classes <- tibble::tibble(class_dataframe1 = purrr::map_chr(dataframe1[,colnames(dataframe1) %in% common_vars], class), Column = common_vars)
df <- dplyr::full_join(dataframe2_classes, dataframe1_classes) %>%
dplyr::filter(class_dataframe2 != class_dataframe1) %>%
dplyr::select(Column, class_dataframe1, class_dataframe2)
names(df) <- c("Column", rlang::expr_text(substitute(dataframe1)), rlang::expr_text(substitute(dataframe2)))
df
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment