create_breaks: A convenience functon for creating breaks with various...

Description Usage Arguments Value See Also Examples

Description

A convenience functon for creating breaks with various methods.

Usage

1
create_breaks(x, y = NULL, method = "kmeans", control = NULL, ...)

Arguments

x

X is a numeric vector to be discretized

y

Y is the response vector used for calculating metrics for discretization

method

Method is the type of discretization approach used. Possible methods are: "dt", "entropy", "kmeans", "jenks"

control

Control is used for optional parameters for the method. It is a list of optional parameters for the function

...

instead of passing a list into control, arguments can be parsed as is.

Value

A vector containing the breaks

See Also

get_control, create_bins

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
kmeans_breaks <- create_breaks(1:10)
create_bins(1:10, kmeans_breaks)

# passing the k means parameter "centers" = 4
kmeans_breaks <- create_breaks(1:10, list(centers=4))
create_bins(1:10, kmeans_breaks)

entropy_breaks <- create_breaks(1:10, rep(c(1,2), each = 5), method="entropy")
create_bins(1:10, entropy_breaks)

dt_breaks <- create_breaks(iris$Sepal.Length, iris$Species, method="dt")
create_bins(iris$Sepal.Length, dt_breaks)

Example output

 [1] 1 1 1 2 2 2 3 3 3 3
 [1] 1 1 1 1 2 2 2 3 3 3
 [1] 1 1 1 1 1 2 2 2 2 2
  [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 2
 [38] 1 1 1 1 1 1 1 1 1 1 1 1 1 3 3 3 2 3 2 3 1 3 1 1 2 2 2 2 3 2 2 3 2 2 2 3 2
 [75] 3 3 3 3 2 2 2 2 2 2 1 2 3 3 2 2 2 2 2 1 2 2 2 3 1 2 3 2 4 3 3 4 1 4 3 4 3
[112] 3 3 2 2 3 3 4 4 2 3 2 4 3 3 4 3 2 3 4 4 4 3 3 2 4 3 3 2 3 3 3 2 3 3 3 3 3
[149] 3 2

binst documentation built on May 2, 2019, 7:32 a.m.

Related to create_breaks in binst...