Learn R Programming

SparkR (version 3.1.2)

count: Count

Description

Count the number of rows for each group when we have GroupedData input. The resulting SparkDataFrame will also contain the grouping columns.

This can be used as a column aggregate function with Column as input, and returns the number of items in a group.

Usage

count(x)

n(x)

# S4 method for GroupedData count(x)

# S4 method for Column count(x)

# S4 method for Column n(x)

Arguments

x

a GroupedData or Column.

Value

A SparkDataFrame.

See Also

Other aggregate functions: avg(), column_aggregate_functions, corr(), cov(), first(), last()

Examples

Run this code
# NOT RUN {
  count(groupBy(df, "name"))
# }
# NOT RUN {
count(df$c)
# }
# NOT RUN {
n(df$c)
# }

Run the code above in your browser using DataLab