num_cut_fct: Convert factor from 'cut' to numeric

View source: R/num_cut_fct.R

num_cut_fctR Documentation

Convert factor from cut to numeric

Description

After using cut, this function will convert the resulting interval to numeric values, which correspond to the middle of the interval.

Usage

num_cut_fct(x, digits)

Arguments

x

factor, output from cut

digits

optional, use round on the result with specific digits

Value

numeric vector of same length as x

Examples

x <- runif(10, 0, 3000)
x_cut <- cut(x, breaks = 0:3 * 1000)
num_cut_fct(x_cut)

# compare the differences:
data.frame(x, x_cut, num_cut_fct(x_cut))


mitmat/mitmatmisc documentation built on Aug. 22, 2024, 3:28 a.m.