between: Classify values into groups based on which numbers they're...

Description Usage Arguments Value See Also Examples

View source: R/Rfunctions.R

Description

Classify values into groups based on which numbers they're between. quantile.cutpoints creates a data.frame of quantiles for feeding into e.g. categorize()

Usage

1
2
3
4
5
  between(vec, cutpoints)

  bin(vec, n = 10)

  quantile_cutpoints(vec, probs)

Arguments

vec

Numeric vector to classify

cutpoints

Vector listing what values the grouping should be done on. Should include the max and the min in this list as well.

n

Number of groups to bin into

probs

Probabilities at which to create cutpoints

Value

Vector of length(vec) indicating which group each element is in (for between). Or vector of length(vec) indicating the lower bound of the group that it's in.

See Also

categorize

Examples

1
2
3
test <- runif(100)
between(test,c(0,.1,.5,.9,1))
bin(test,n=5)

Example output

  [1] 2 2 4 1 2 3 2 2 3 2 2 3 4 3 2 3 3 3 3 2 2 2 2 3 4 3 2 1 4 2 4 1 2 3 3 3 3
 [38] 2 1 2 4 2 3 3 2 2 2 1 2 3 3 2 3 3 2 3 3 2 3 1 3 2 1 2 3 2 2 3 2 3 3 2 3 3
 [75] 3 2 2 1 2 2 3 2 3 2 1 3 4 3 3 2 1 2 3 3 2 2 3 3 2 3
  [1] 0.36377958 0.01767067 0.80453897 0.01767067 0.18865208 0.55984570
  [7] 0.01767067 0.18865208 0.55984570 0.18865208 0.36377958 0.55984570
 [13] 0.80453897 0.80453897 0.01767067 0.80453897 0.55984570 0.36377958
 [19] 0.55984570 0.36377958 0.01767067 0.18865208 0.18865208 0.55984570
 [25] 0.80453897 0.55984570 0.01767067 0.01767067 0.80453897 0.18865208
 [31] 0.80453897 0.01767067 0.18865208 0.36377958 0.55984570 0.80453897
 [37] 0.36377958 0.36377958 0.01767067 0.01767067 0.80453897 0.36377958
 [43] 0.80453897 0.55984570 0.01767067 0.18865208 0.18865208 0.01767067
 [49] 0.18865208 0.55984570 0.55984570 0.01767067 0.80453897 0.55984570
 [55] 0.18865208 0.80453897 0.80453897 0.01767067 0.55984570 0.01767067
 [61] 0.80453897 0.18865208 0.01767067 0.18865208 0.55984570 0.36377958
 [67] 0.36377958 0.80453897 0.36377958 0.55984570 0.55984570 0.01767067
 [73] 0.36377958 0.80453897 0.80453897 0.36377958 0.36377958 0.01767067
 [79] 0.18865208 0.18865208 0.80453897 0.18865208 0.55984570 0.36377958
 [85] 0.01767067 0.55984570 0.80453897 0.55984570 0.36377958 0.18865208
 [91] 0.01767067 0.18865208 0.80453897 0.36377958 0.18865208 0.36377958
 [97] 0.36377958 0.36377958 0.18865208 0.55984570

taRifx documentation built on April 14, 2020, 6:27 p.m.

Related to between in taRifx...