arrange

The arrange function sorts your SparkR DataFrame on the specified column(s). Results are returned in ascending order by default.

Syntax:

  • arrange(DataFrame, “colName”, ...)
  • arrange(DataFrame, DataFrame$colName, ...)

Parameters:

  • DataFrame: Any SparkR DataFrame
  • colName: Column in DataFrame

Output:

  • SparkR DataFrame
# Create SparkR DataFrame
df <- createDataFrame(sqlContext, airquality)
head(df)
# Arrange data by ascending Month and ascending Day
head(arrange(df, "Month", "Day"))
# Arrange data by descending Wind
head(arrange(df, desc(df$Wind)))