SparkR (version 2.1.2)

row_number: row_number

Description

Window function: returns a sequential number starting at 1 within a window partition.

Usage

row_number(x = "missing")

# S4 method for missing row_number()

Arguments

x

empty. Should be used with no argument.

Details

This is equivalent to the ROW_NUMBER function in SQL.

See Also

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

Examples

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

Run the code above in your browser using DataCamp Workspace