h2o (version 3.2.0.3)

h2o.cut: Cut H2O Numeric Data to Factor

Description

Divides the range of the H2O data into intervals and codes the values according to which interval they fall in. The leftmost interval corresponds to the level one, the next is level two, etc.

Usage

h2o.cut(x, breaks, labels = NULL, include.lowest = FALSE, right = TRUE,
  dig.lab = 3, ...)

Arguments

x
An H2OFrame object with numeric columns.
breaks
A numeric vector of two or more unique cut points.
labels
Labels for the levels of the resulting category. By default, labels are constructed sing "(a,b]" interval notation.
include.lowest
Logical, indicationg if an 'x[i]' equal to the lowest (or highest, for right = FALSE 'breaks' value should be included
right
/code{Logical}, indicating if the intervals should be closed on the right (opened on the left) or vice versa.
dig.lab
Integer which is used when labels are not given, determines the number of digits used in formatting the beak numbers.
...
Further arguments passed to or from other methods.

Value

  • Returns an H2OFrame object containing the factored data with intervals as levels.

Examples

Run this code
library(h2o)
localH2O <- h2o.init()
irisPath <- system.file("extdata", "iris_wheader.csv", package="h2o")
iris.hex <- h2o.uploadFile(localH2O, path = irisPath, destination_frame = "iris.hex")
summary(iris.hex)

# Cut sepal length column into intervals determined by min/max/quantiles
sepal_len.cut = cut(iris.hex$sepal_len, c(4.2, 4.8, 5.8, 6, 8))
head(sepal_len.cut)
summary(sepal_len.cut)

Run the code above in your browser using DataLab