SparkR (version 2.4.6)

over: over

Description

Define a windowing column.

Usage

over(x, window)

# S4 method for Column,WindowSpec over(x, window)

Arguments

x

a Column, usually one returned by window function(s).

window

a WindowSpec object. Can be created by windowPartitionBy or windowOrderBy and configured by other WindowSpec methods.

See Also

Other colum_func: alias(), between(), cast(), endsWith(), otherwise(), startsWith(), substr()

Examples

Run this code
# NOT RUN {
  df <- createDataFrame(mtcars)

  # Partition by am (transmission) and order by hp (horsepower)
  ws <- orderBy(windowPartitionBy("am"), "hp")

  # Rank on hp within each partition
  out <- select(df, over(rank(), ws), df$hp, df$am)

  # Lag mpg values by 1 row on the partition-and-ordered table
  out <- select(df, over(lead(df$mpg), ws), df$mpg, df$hp, df$am)
# }

Run the code above in your browser using DataLab