R/bin_ages.R

Defines functions bin_ages

Documented in bin_ages

#' bin_ages
#'
#' @param x data
#' @param N number of bins
#'
bin_ages <- function(x, N) {
  max_age <- ceiling(max(x$age))
  jump <- floor(max_age / (N-1))

  x %>% dplyr::mutate(age_group = ggplot2::cut_number(.data$age, 10),
                      age_group2 = ggplot2::cut_interval(.data$age, 10))
}
soniamitchell/SpARKjags documentation built on May 5, 2022, 12:09 p.m.