sumΒΆ

sum is an aggregate function that returns the sum of all values in the specified column.

Syntax:

  • sum(df$col)

Parameters:

  • df: Any SparkR DataFrame
  • col: Column in SparkR DataFrame

Output:

  • Column Object
# Create SparkR DataFrame
df <- createDataFrame(mtcars)
head(df)
# Sum total mpg in df
head(select(df, sum(df$mpg)))