R/calc_breaks.R

# Function for all cases when we need breaks calculated
calc_breaks <- function(vals, breaks = "Sturges", threshold = NULL) {
  if(length(unique(vals)) > 5) {
    br <- hist(vals, breaks = breaks, plot = FALSE)[["breaks"]]
    cut(vals, breaks = br, include.lowest = TRUE)
  } else {
    factor(vals)
  }
}

Try the dpcR package in your browser

Any scripts or data that you put into this service are public.

dpcR documentation built on May 2, 2019, 7:04 a.m.