Skip to content

Instantly share code, notes, and snippets.

@BenHeubl
Created February 13, 2020 16:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BenHeubl/de57feb16d8f5fd127df283242d0c1f8 to your computer and use it in GitHub Desktop.
Save BenHeubl/de57feb16d8f5fd127df283242d0c1f8 to your computer and use it in GitHub Desktop.
tut16
#mode function
getmode <- function(v) {
uniqv <- unique(v)
uniqv[which.max(tabulate(match(v, uniqv)))]
}
incomeR_mode_income <- incomeR %>%
group_by(INCOME) %>%
summarise(mode = getmode(OCCUPATION))
incomeR_mode_income
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment