Reorders levels of factor columns by the frequencies for the individual levels.
Reorders levels of factor columns by the frequencies for the individual levels.
The levels of a factor are reordered so that the most frequency level is at level 0, remaining levels are ordered from the second most frequent to the least frequent.
top_n: optional number of most frequent levels to move to the top (eg.: for top_n=1 move only the most frequent level)
Returns
new reordered frame
Examples
## Not run:library(h2o)h2o.init()# Convert iris dataset to an H2OFrameiris_hf <- as.h2o(iris)# Look at current ordering of the Species column levelsh2o.levels(iris_hf["Species"])# "setosa" "versicolor" "virginica" # Change the reference level to "virginica"iris_hf["Species"]<- h2o.relevel_by_frequency(x = iris_hf["Species"])# Observe new orderingh2o.levels(iris_hf["Species"])# "virginica" "versicolor" "setosa"## End(Not run)