## ---- include = FALSE--------------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) ## ----setup-------------------------------------------------------------------- library(moder) ## ----------------------------------------------------------------------------- x1 <- c(7, 7, 7, 8, 8, 9, 9, NA) mean(x1) median(x1) ## ----------------------------------------------------------------------------- x1 mode_first(x1) mode_all(x1) ## ----------------------------------------------------------------------------- x2 <- c(1, 1, 1, 1, 1, 0, 0, NA, NA) mode_first(x2) mode_all(x2) ## ----------------------------------------------------------------------------- x1 mode_possible_min(x1) ## ----------------------------------------------------------------------------- mode_possible_min(c("a", "a", "a", "b", "b", "c", NA)) ## ----------------------------------------------------------------------------- mode_possible_min(c(TRUE, TRUE, FALSE, NA, NA)) ## ----------------------------------------------------------------------------- mode_possible_max(c("a", "a", "a", "b", "b", "c", NA)) ## ----------------------------------------------------------------------------- x1 mode_possible_max(x1) mode_possible_max(c(x1, 7)) ## ----------------------------------------------------------------------------- x1 mean(x1, na.rm = TRUE) median(x1, na.rm = TRUE) mode_all(x1, na.rm = TRUE) ## ----------------------------------------------------------------------------- x4 <- c(6, 4, 4, 4, NA, NA, 1) mode_first(x4) mode_first(x4, accept = TRUE) ## ----------------------------------------------------------------------------- x5 <- c(4, 4, 4, 7, 7, NA) mode_single(x5) mode_single(x5, accept = TRUE)