Skip to content

Instantly share code, notes, and snippets.

@verajosemanuel
Last active November 14, 2017 09:34
Show Gist options
  • Save verajosemanuel/6b0180b610e99f46cdbc14bbeb26908d to your computer and use it in GitHub Desktop.
Save verajosemanuel/6b0180b610e99f46cdbc14bbeb26908d to your computer and use it in GitHub Desktop.
#janitor tools #R #packages #wrangling
library(janitor)
df <- remove_empty_rows(df)
df <- remove_empty_cols(df)
# clean names
names(df) <- names(clean_names(df))
# summarize frequencies
tabyl(df$column_name)
# using pipes
library(magrittr)
df <- clean_names() %>%
remove_empty_rows() %>%
remove_empty_cols() %>%
convert_to_NA(c("column1", "column2")) %>%
# detect duplicates
df %>% get_dupes(first_col, last_col)
# crosstabs
df %>%
tabyl(column_1, sort = TRUE) %>%
add_totals_row()
df %>%
crosstab(column1, column2) %>%
adorn_crosstab(denom = "col", show_totals = TRUE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment