Learn R Programming

sdsfun (version 0.7.0)

discretize_vector: discretization

Description

discretization

Usage

discretize_vector(
  x,
  n,
  method = "natural",
  breakpoint = NULL,
  sampleprob = 0.15,
  seed = 123456789
)

Value

A discretized integer vector

Arguments

x

A continuous numeric vector.

n

(optional) The number of discretized classes.

method

(optional) The method of discretization, default is natural.

breakpoint

(optional) Break points for manually splitting data. When method is manual, breakpoint is required.

sampleprob

(optional) When the data size exceeds 3000, perform sampling for discretization, applicable only to natural breaks. Default is 0.15.

seed

(optional) Random seed number, default is 123456789.

Examples

Run this code
xvar = c(22361, 9573, 4836, 5309, 10384, 4359, 11016, 4414, 3327, 3408,
         17816, 6909, 6936, 7990, 3758, 3569, 21965, 3605, 2181, 1892,
         2459, 2934, 6399, 8578, 8537, 4840, 12132, 3734, 4372, 9073,
         7508, 5203)
discretize_vector(xvar, n = 5, method = 'natural')

Run the code above in your browser using DataLab