divide_by_quantile {lvmisc}R Documentation

Divide variable based on quantiles

Description

Creates a factor based on equally spaced quantiles of a variable.

Usage

divide_by_quantile(data, n, na.rm = TRUE)

Arguments

data

A numeric vector.

n

An integer specifying the number of levels in the factor to be created.

na.rm

A logical vector indicating whether the NA values should be removed before the quantiles are computed.

Value

A vector of class factor indicating in which quantile the element in data belongs.

See Also

stats::quantile().

Examples

x <- c(sample(1:20, 9), NA)
divide_by_quantile(x, 3)

[Package lvmisc version 0.1.2 Index]