countΒΆ

The count function returns the number of rows in a SparkDataFrame

Syntax:

  • count(data)

Parameters:

  • data: Any SparkDataFrame or GroupedData

Output:

  • Local R data frame
require(SparkR)

# Create SparkDataFrame
df <- createDataFrame(airquality)
count(df)

You can also use count to count the number of rows in each group in GroupedData.

# Count occurences of each Ozone value
collect(arrange(count(groupBy(df, "Ozone")), "Ozone"))