classifyByQuantiles: 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
classifyByQuantiles(x, n.main = 10, n.supp = 4, i.class.zero = FALSE,
  format.level = FALSE, ordered.factor = FALSE)

Arguments

x

numieric vector

n.main

number of main groups

n.supp

number of supplement groups - total size of which equals sizt of one main group

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
15
16
17
18
19
20
21
22
23
24
25
 data(swiss)
 summary(swiss$Agriculture)
 x            <- swiss$Agriculture
 x[c(3, 6, 9, 22)] <- NA
 n.main       <- 6
 n.supp       <- 2
 i.class.zero <- 1
 i.class.zero <- 0
 format.level <- TRUE
 y <- classifyByQuantiles(x = x, n.main = n.main, n.supp = n.supp,
                          i.class.zero = i.class.zero,
                          format.level = format.level)
 str(y)
 levels(y)
 table(y, useNA = "always")
 sum(table(y, useNA = "always"))


 format.level <- FALSE
 y <- classifyByQuantiles(x = x, n.main = n.main, n.supp = n.supp,
                          i.class.zero = i.class.zero,
                          format.level = format.level)
 str(y)
 levels(y)
 table(y, useNA = "always")

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