discretize {gtexture} | R Documentation |
Discretize Numeric Variable Into Categories
Description
Takes a numeric variable (could be of class numeric
or integer
) and
returns a discretized version, in which each element has been replaced by a
single integer between 1
and nlevels
, inclusive.
Usage
discretize(x, ...)
## S3 method for class 'numeric'
discretize(x, nlevels, method = "equal", ...)
## S3 method for class 'list'
discretize(x, nlevels, ...)
## S3 method for class 'integer'
discretize(x, nlevels, ...)
## S3 method for class 'FitLandDF'
discretize(x, nlevels, ...)
Arguments
x |
either a vector ( |
... |
potential additional arguments, currently unnecessary |
nlevels |
positive integer indicating number of discrete categories |
method |
method by which to discretize; split into equal sections by
default ( |
Value
discretized form of x
Examples
## discretize a numeric vector
vec <- 1:10
discretize(vec, nlevels = 5) # discretize into 5 categories
discretize(vec, 2) # discretize into 2 categories
## discretize a fitness landscape
# create a 3x3x3 fitness landscape with values 1 through 27
fl_data <- array(1:27, dim = rep(3, 3))
my_fl <- fitscape::FitLandDF(fl_data)
discretize(my_fl, nlevels = 2) # discretize landscape into 2 categories
discretize(my_fl, 5) # discretize landscape into 5 categories
[Package gtexture version 1.0.0 Index]