Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment