The default var() and sd() R functions calculate the sample variance and standard deviation. But what if you want the population variance or standard deviation? Say hello to {popstats}!

Installation

You can install the released version of popstats from GitHub with:

# install {remotes} package if not available
# install.packages("remotes")
remotes::install_github(repo = "hamedbh/popstats")

Example

library(popstats)
pop_var(1:10)
#> 8.25

pop_var(c(1:10, NA))
#> NA

pop_var(c(1:10, NA), na.rm = TRUE)
#> 8.25