arrangeΒΆ

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

Syntax:

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

Parameters:

  • SparkDataFrame: Any SparkDataFrame
  • colName: Column in SparkDataFrame

Output:

  • SparkDataFrame
require(SparkR)

# Create SparkDataFrame
df <- createDataFrame(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)))