classifyByBreaks {rrMisc} | R Documentation |
Group numerical vector and allow for group with zero values as well as formating
classifyByBreaks( x, breaks, i.class.zero = FALSE, format.level = FALSE, ordered.factor = FALSE )
x |
numieric vector |
breaks |
first lower bound and all following upper bounds |
i.class.zero |
indicator for a separate group vor zero values |
format.level |
indicator for levels to be formatted |
ordered.factor |
to be given to cut() |
utility function for better grouping numerical valures
grouped factor vector
Roland Rapold
x <- as.integer(c(rep(0, 10), rep(1, 8), rep(2, 6), rep(3, 6), rep(4, 4), 5, 5, 5, 6, 6, 7, 8, 9)) breaks <- c(0, 1, 2, 3, 5, 9) y <- classifyByBreaks(x = x, breaks = breaks, format.level = FALSE) table(y, useNA = "always") y <- classifyByBreaks(x = x, breaks = breaks, format.level = TRUE) table(y, useNA = "always") y <- classifyByBreaks(x = x, breaks = breaks, i.class.zero = 1, format.level = FALSE) table(y, useNA = "always") y <- classifyByBreaks(x = x, breaks = breaks, i.class.zero = 1, format.level = TRUE) table(y, useNA = "always")