classifyByBreaks: Group numerical vector (enhanced cut())

Description Usage Arguments Details Value Author(s) Examples

View source: R/modify.R

Description

Group numerical vector and allow for group with zero values as well as formating

Usage

1
2
classifyByBreaks(x, breaks, i.class.zero = FALSE, format.level = FALSE,
  ordered.factor = FALSE)

Arguments

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()

Details

utility function for better grouping numerical valures

Value

grouped factor vector

Author(s)

Roland Rapold

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
 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")

rrMisc documentation built on June 25, 2021, 3 a.m.