rank {SparkR}R Documentation

rank

Description

Window function: returns the rank of rows within a window partition.

Usage

## S4 method for signature 'missing'
rank()

## S4 method for signature 'ANY'
rank(x, ...)

rank(x, ...)

Arguments

x

a numeric, complex, character or logical vector.

...

additional argument(s) passed to the method.

Details

The difference between rank and denseRank is that denseRank leaves no gaps in ranking sequence when there are ties. That is, if you were ranking a competition using denseRank and had three people tie for second place, you would say that all three were in second place and that the next person came in third.

This is equivalent to the RANK function in SQL.

Note

rank since 1.6.0

See Also

Other window_funcs: cume_dist, cume_dist, cume_dist,missing-method; dense_rank, dense_rank, dense_rank,missing-method; lag, lag, lag,characterOrColumn-method; lead, lead, lead,characterOrColumn,numeric-method; ntile, ntile, ntile,numeric-method; percent_rank, percent_rank, percent_rank,missing-method; row_number, row_number, row_number,missing-method

Examples

## Not run: 
##D   df <- createDataFrame(mtcars)
##D   ws <- orderBy(windowPartitionBy("am"), "hp")
##D   out <- select(df, over(rank(), ws), df$hp, df$am)
## End(Not run)

[Package SparkR version 2.1.0 Index]