R/categorical-features.R

get_mode <- function(x) {
  table(x) %>%
    which.max() %>%
    names()
}

count_mode <- function(x) {
  table(x) %>%
    max()
}

pct_mode <- function(x) {
  (table(x) / length(x)) %>%
    max() %>%
    round(., 3)
}

count_non_alphanum <- function(x) {
  stringr::str_detect(x, "[^[:alnum:]]") %>%
    sum()
}
dannymorris/colstats documentation built on May 31, 2019, 5:40 a.m.