Learn R Programming

gtexture (version 1.0.0)

equal_discrete: Function Factory for Even Discretization Functions

Description

Returns a function that converts a continuous numeric vector into an integer vector with discrete levels.

Usage

equal_discrete(nlevels)

Value

function that makes a numeric vector discrete

Arguments

nlevels

number of levels to split continuous vector into

Examples

Run this code
# test data
x <- 1:10

# create and apply function to split x into 2 discrete levels
split_2 <- equal_discrete(2)
split_2(x)

# create and apply function to split x into 5 discrete levels
split_5 <- equal_discrete(5)
split_5(x)

Run the code above in your browser using DataLab