agg {SparkR} | R Documentation |
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.
## 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, ...)
x |
a DataFrame |
x |
a GroupedData |
x |
a GroupedData |
df2 <- agg(df, <column> = <aggFunction>) df2 <- agg(df, newColName = aggFunction(column))
a DataFrame
a DataFrame
## 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)