sum
Sums and Products

Description

Returns the sum or product of all of the elements of all of the arguments. Missing values (NAs) are allowed, but you can remove them prior to performing any computation.

Usage

sum(..., na.rm = FALSE)
prod(..., na.rm = FALSE)

Arguments

... numeric or complex objects. Missing values (NAs) are allowed.
na.rm a logical value. TRUE specifies that missing values should be removed before computations are performed. If the elements include missing values, and you do not specify na.rm = TRUE, the return value is NA. The default is FALSE.

Details

These functions are members of the Summary group of generic functions.
Value
returns the sum or product of all elements of all arguments. If the total length of all the arguments is 0, sum returns 0 and prod returns 1.
See Also
cumsum, Arithmetic
Examples
geo.mean <- function(x) prod(x)^(1/length(x))
sum(1:4)
Package base version 6.0.0-69
Package Index