Last active
May 27, 2021 15:50
-
-
Save rbjanis/44dbcecb2c96c11defdb7892ad8158fb to your computer and use it in GitHub Desktop.
Compare classes of columns common to two data sets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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