# Logical column -> predicates for TRUE and FALSE
x <- tibble::tibble(a = c(TRUE, FALSE, NA, TRUE))
partition(x, a)
# Factor column -> predicates for individual levels
x <- tibble::tibble(a = factor(c("low", "medium", "high", NA)))
partition(x, a)
# Unordered factor -> predicates for all pairs of levels
x <- tibble::tibble(a = factor(c("a", "b", "c", "a")))
partition(x, a, .subsets = 2)
# Ordered factor -> only consecutive subsets are created
x <- tibble::tibble(a = ordered(c("low", "medium", "high", "medium"),
levels = c("low", "medium", "high")))
partition(x, a, .subsets = 2)
# Keep original selected columns
partition(CO2, Plant, .keep = TRUE)
# Suppress explicit NA predicate
x <- tibble::tibble(a = c(TRUE, FALSE, NA))
partition(x, a, .na = FALSE)
# Numeric data treated as ordered categories
x <- tibble::tibble(a = c(1, 2, 2, 3, 4))
partition(x, a, .method = "dummy")
# Numeric data treated as ordered categories with consecutive pairs
partition(x, a, .method = "dummy", .subsets = 2)
# Crisp transformation using equal-width bins
partition(CO2, conc, .method = "crisp", .breaks = 4)
# Crisp transformation using quantile-based bins
partition(CO2, conc, .method = "crisp", .breaks = 4, .style = "quantile")
# Crisp transformation using k-means clustering for breakpoints
partition(CO2, conc, .method = "crisp", .breaks = 4, .style = "kmeans")
# Crisp transformation using Lloyd algorithm for k-means breakpoints
partition(CO2, conc, .method = "crisp", .breaks = 4, .style = "kmeans",
.style_params = list(algorithm = "Lloyd"))
# Crisp transformation with manually specified breaks
partition(CO2, conc, .method = "crisp",
.breaks = c(-Inf, 200, 500, 800, Inf))
# Crisp transformation with overlapping intervals
partition(CO2, conc, .method = "crisp",
.breaks = c(1, 3, 5, 7, 9, 11),
.span = 2, .inc = 1)
# Crisp transformation with left-closed, right-open intervals
partition(CO2, conc, .method = "crisp", .breaks = 4, .right = FALSE)
# Fuzzy triangular transformation
partition(CO2, conc:uptake, .method = "triangle", .breaks = 3)
# Raised-cosine fuzzy predicates
partition(CO2, conc:uptake, .method = "raisedcos", .breaks = 3)
# Trapezoidal fuzzy predicates
partition(CO2, conc:uptake, .method = "triangle", .breaks = 3, .span = 2)
# Overlapping trapezoidal fuzzy predicates (Ruspini condition)
partition(CO2, conc:uptake, .method = "triangle", .breaks = 3,
.span = 2, .inc = 2)
# Fuzzy transformation with manually specified breaks
partition(CO2, uptake,
.method = "triangle",
.breaks = c(-Inf, 7.7, 28.3, 45.5, Inf))
# Fuzzy transformation with custom labels
partition(CO2, uptake,
.method = "triangle",
.breaks = c(-Inf, 7.7, 28.3, 45.5, Inf),
.labels = c("low", "medium", "high"))
# Different settings can be applied in successive calls
CO2 |>
partition(Plant:Treatment) |>
partition(conc,
.method = "raisedcos",
.breaks = c(-Inf, 95, 175, 350, 675, 1000, Inf)) |>
partition(uptake,
.method = "triangle",
.breaks = c(-Inf, 7.7, 28.3, 45.5, Inf),
.labels = c("low", "medium", "high"))
Run the code above in your browser using DataLab