Skip to content

Compute the sum of a Series

Source code

Description

Compute the sum of a Series

Usage

<Series>$sum()

Details

The Dtypes Int8, UInt8, Int16 and UInt16 are cast to Int64 before summing to prevent overflow issues.

Value

A numeric value

Examples

library("polars")

as_polars_series(c(1:2, NA, 3, 5))$sum() # a NA is dropped always
#> [1] 11
as_polars_series(c(1:2, NA, 3, NaN, 4, Inf))$sum() # NaN poisons the result
#> [1] NaN
as_polars_series(c(1:2, 3, Inf, 4, -Inf, 5))$sum() # Inf-Inf is NaN
#> [1] NaN