agg {SparkR}R Documentation

Summarize data across columns

Description

Compute aggregates by specifying a list of columns

Count the number of rows for each group. The resulting DataFrame will also contain the grouping columns.

Aggregates on the entire DataFrame without groups. The resulting DataFrame will also contain the grouping columns.

Usage

## S4 method for signature 'DataFrame'
agg(x, ...)

## S4 method for signature 'DataFrame'
summarize(x, ...)

agg(x, ...)

summarize(x, ...)

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

## S4 method for signature 'GroupedData'
agg(x, ...)

## S4 method for signature 'GroupedData'
summarize(x, ...)

Arguments

x

a DataFrame

x

a GroupedData

x

a GroupedData

Details

df2 <- agg(df, <column> = <aggFunction>) df2 <- agg(df, newColName = aggFunction(column))

Value

a DataFrame

a DataFrame

Examples

## Not run: 
##D   count(groupBy(df, "name"))
## End(Not run)
## Not run: 
##D  df2 <- agg(df, age = "sum")  # new column name will be created as 'SUM(age#0)'
##D  df2 <- agg(df, ageSum = sum(df$age)) # Creates a new column named ageSum
## End(Not run)

[Package SparkR version 1.5.1 Index]