count: Count

Description Usage Arguments Value Note See Also Examples

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
count(x)

n(x)

## S4 method for signature 'GroupedData'
count(x)

## S4 method for signature 'Column'
count(x)

## S4 method for signature 'Column'
n(x)

Arguments

x

a GroupedData or Column.

Value

A SparkDataFrame.

Note

count since 1.4.0

count since 1.4.0

n since 1.4.0

See Also

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

Examples

1
2
3
4
5
6
## Not run: 
  count(groupBy(df, "name"))

## End(Not run)
## Not run: count(df$c)
## Not run: n(df$c)

SparkR documentation built on June 3, 2021, 5:05 p.m.