# wafflecut: Like 'cut', turn a vector of numbers into a factor In fancycut: A Fancy Version of 'base::cut'

## Description

Like `cut`, turn a vector of numbers into a factor

## Usage

 ```1 2``` ```wafflecut(x, intervals, buckets = intervals, na.bucket = NA, unmatched.bucket = NA, out.as.factor = TRUE) ```

## Arguments

 `x` a numeric vector `intervals` a character vector of intervals `buckets` a character vector of levels for the new factor these have a 1-1 correspondence with `intervals` `na.bucket` what level should NA values be given? `unmatched.bucket` what level should numbers not covered by an interval be given? `out.as.factor` default is TRUE Should the resulting vector be a factor? If FALSE will return a character vector.

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23``` ```wafflecut(-10:10, c('[0,2)','[2,5)','[5,10]'), c('Small','Medium','Large')) wafflecut(-10:10, c('[0,0]','(0,2]','(2,5)','[5,10]'), c('Zero','Small','Medium','Large')) wafflecut(-10:10, c('[0,2)','[2,5)','[5,10]'), c('Small','Medium','Large')) wafflecut(-10:10, c('[0,0]','[0,2]','(2,5)','[5,10]'), c('Zero','Small','Medium','Large')) # The following examples are from Richie Cotton via # https://www.rdocumentation.org/packages/fancycut/versions/0.1.1/topics/fancycut # Not all the values have to live in a bucket. x <- seq.int(0, 1, 0.25) wafflecut(x, c('(0.2, 0.3)', '(0.7, 0.8)'), c('low', 'high')) # You can use unmatched.bucket to deal with these other intervals. x <- seq.int(0, 1, 0.25) wafflecut(x, c('(0.2, 0.3)', '(0.7, 0.8)'), c('low', 'high'), unmatched.bucket = 'other') # To match NA values, use na.bucket. x2 <- c(seq.int(0, 1, 0.25), NA) wafflecut(x2, c('[0, 0.5)', '[0.5, 1]'), c('low', 'high'), na.bucket = 'missing') ```

fancycut documentation built on May 2, 2019, 5:56 a.m.