Learn R Programming

soc.ca (version 0.8.0)

min_cut: Cut a continuous variable into categories with a specified minimum

Description

Many continuous variables are very unequally distributed, often with many individuals in the lower categories and fewer in the top. As a result it is often difficult to create groups of equal size, with unique cut-points. By defining the wanted minimum of individuals in each category, but still allowing this minimum to be surpassed, it is easy to create ordinal variables from continuous variables. The last category will not neccessarily have the minimum number of individuals.

Usage

min_cut(x, min.size = length(x)/10)

Arguments

x

is a continuous numerical variable

min.size

is the minimum number of individuals in each category

Value

a numerical vector with the number of each category

Examples

Run this code
# NOT RUN {
a <- 1:1000
table(min_cut(a))
b <- c(rep(0, 50), 1:500)
table(min_cut(b, min.size = 20))

# }

Run the code above in your browser using DataLab