Skip to contents

This function computes the standard error (i.e. sd / sqrt(n)) of the values in x. If na.rm is TRUE then missing values are removed before computation proceeds.

Usage

se(x, na.rm = FALSE)

Arguments

x

A numeric vector or an R object which is coercible to one by as.vector.

na.rm

Logical. Should missing values be removed?

Value

A numeric.

See also

var and sd for the variance and standard deviation.

Author

From the manual "An Introduction to R", modified by Mathieu Basille <\email{mathieu@basille.org}>

Examples

bla <- rnorm(1000, sd = 100)
sd(bla)
#> [1] 99.32545
sqrt(var(bla)/length(bla))
#> [1] 3.140947
se(bla)
#> [1] 3.140947

is.na(bla) <- 200:300
sd(bla, na.rm = TRUE)
#> [1] 99.53578
se(bla, na.rm = TRUE)
#> [1] 3.319704