SparkR (version 2.1.2)

percent_rank: percent_rank

Description

Window function: returns the relative rank (i.e. percentile) of rows within a window partition.

Usage

percent_rank(x = "missing")

# S4 method for missing percent_rank()

Arguments

x

empty. Should be used with no argument.

Details

This is computed by:

(rank of row in its partition - 1) / (number of rows in the partition - 1)

This is equivalent to the PERCENT_RANK function in SQL.

See Also

Other window_funcs: cume_dist, dense_rank, lag, lead, ntile, rank, row_number

Examples

Run this code
# NOT RUN {
  df <- createDataFrame(mtcars)
  ws <- orderBy(windowPartitionBy("am"), "hp")
  out <- select(df, over(percent_rank(), ws), df$hp, df$am)
# }

Run the code above in your browser using DataLab