Learn R Programming

h2o (version 2.8.4.4)

Round: Rounding of Numbers

Description

round rounds the values in a H2OParsedData object to the specified number of decimal places.

signif rounds the values in a H2OParsedData object to the specified number of significant digits.

Usage

## S3 method for class 'H2OParsedData':
round(x, digits = 0)
## S3 method for class 'H2OParsedData':
signif(x, digits = 6)

Arguments

x
An H2OParsedData object with numeric entries.
digits
Single number specifying decimal places (round) or significant digits (signif) to use. Negative values are interpreted as a power of ten, e.g. round(x, digits = -2) round to the nearest hundred.

Value

  • Returns a H2OParsedData object with each entry rounded as specified. An error will occur if any of these entries is non-numeric.

Details

This method uses the IEC 60559 standard for rounding to the even digit, so 0.5 goes to 0 and -1.5 goes to -2. See the Java documentation of RoundingMode.HALF_EVEN for more details and examples.

Examples

Run this code
library(h2o)
localH2O = h2o.init()
irisPath = system.file("extdata", "iris.csv", package="h2o")
iris.hex = h2o.importFile(localH2O, path = irisPath)
iris.data = iris.hex[,1:3]

iris.rounded = round(iris.data)
head(iris.rounded)
iris.signif = signif(iris.data, 2)
head(iris.signif)

Run the code above in your browser using DataLab