Last active
November 21, 2020 16:52
-
-
Save mark-andrews/bdf9c458d9f3584d1a59838350380ce7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# View the dummy code of a categorical variable | |
# assumes package fastDummies is installed | |
# assumes tidyverse is installed | |
# Usage: | |
get_dummy_code <- function(Df, variable){ | |
tmp_df <- fastDummies::dummy_cols(Df, remove_first_dummy = TRUE) | |
tmp_df <- dplyr::select(tmp_df, dplyr::starts_with(variable)) | |
dplyr::arrange(dplyr::distinct(tmp_df), !!variable) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment