discretize | R Documentation |
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.
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, ...)
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 ( |
discretized form of x
## 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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.