Skip to content

Compute the mean of a Series

Source code

Description

Compute the mean of a Series

Usage

<Series>$mean()

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))$mean() # a NA is dropped always
#> [1] 2.75
as_polars_series(c(1:2, NA, 3, NaN, 4, Inf))$mean() # NaN carries / poisons
#> [1] NaN
as_polars_series(c(1:2, 3, Inf, 4, -Inf, 5))$mean() # Inf-Inf is NaN
#> [1] NaN