Hadoop Online Training by Edureka

fancycut: Like 'cut', turn a vector of numbers into a factor

Description Usage Arguments Examples

Description

Like cut, turn a vector of numbers into a factor

Usage

1
2
fancycut(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.

...

These take the form tag = value. Tags become the bucket names and values the interval definitions. If args are passed in this way intervals and buckets are both ignored.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
fancycut(-10:10, c('(0,2]','(2,5)','[5,10]'), c('Small','Medium','Large'))
fancycut(-10:10, c('[0,0]','(0,2]','(2,5)','[5,10]'), c('Zero','Small','Medium','Large'))
fancycut(
  x = -10:10,
  Zero = 0,
  Small = '(0,2]',
  Medium = '(2,5)',
  Large = '[5,10]'
)
fancycut(-10:10, c('(0,2]','(2,5)','[5,10]'), c('Small','Medium','Large'))
fancycut(-10:10, c('[0,0]','(0,2]','(2,5)','[5,10]'), c('Zero','Small','Medium','Large'))


Search within the fancycut package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.