Learn R Programming

h2o (version 2.8.4.4)

h2o.order: Returns a permutation which rearranges its first argument into ascending or descending order.

Description

Allows users to find the row indices of entries with the highest or lowest value. To limit the need to do a global search the user can choose the number of indices returned from h2o.order.

Usage

h2o.order(data, cols, n = 5, decreasing = T)

Arguments

data
AnH2OParsedData object.
cols
A vector containing the names or indices of the data columns chosen to be removed.
n
A integer. The number of indices returned, indicating the n rows ordered.
decreasing
Logical. Indicates whether sort should be in increasing or decreasing order.

Examples

Run this code
library(h2o)
localH2O = h2o.init()
prosPath = system.file("extdata", "prostate.csv", package="h2o")
prostate.hex = h2o.importFile(localH2O, path = prosPath, key = "prostate.hex")

# Find ID of the 10 youngest patients in data
indices = h2o.order(data = prostate.hex$AGE, n = 10, decreasing = TRUE)
indices.R = as.matrix(indices)
youngest_patients = prostate.hex[indices.R]

Run the code above in your browser using DataLab