count

The count function returns the number of rows in a DataFrame

Syntax:

  • count(data)

Parameters:

  • data: Any SparkR DataFrame or GroupedData

Output:

  • Local R data frame
# Create SparkR DataFrame
df <- createDataFrame(sqlContext, 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"))