Learn R Programming

daltoolbox (version 1.3.717)

hierarchy_cut: Hierarchy mapping by cut

Description

Create a categorical hierarchy from a numeric attribute using cut points.

Usage

hierarchy_cut(attribute, breaks, labels = NULL, new_attribute = NULL)

Value

returns an object of class hierarchy_cut

Arguments

attribute

numeric attribute to discretize

breaks

numeric breakpoints for cut

labels

optional labels for the cut intervals

new_attribute

name of the new attribute (default: "attribute.Level")

Examples

Run this code
data(iris)
hc <- hierarchy_cut(
 "Sepal.Length",
 breaks = c(-Inf, 5.5, 6.5, Inf),
 labels = c("baixo", "medio", "alto")
)
iris_h <- transform(hc, iris)
table(iris_h$Sepal.Length.Level)

Run the code above in your browser using DataLab