Computes the standard error of the mean (i.e., standard deviation divided by the square root of the sample size).
se(x, na.rm = TRUE)
x | A numeric vector. |
---|---|
na.rm | A logical that indicates whether missing values should be removed before computing the standard error. |
A single numeric that is the standard error of the mean of x
.
See se
in sciplot for similar functionality.
x <- 1:20 sd(x)/sqrt(length(x))#> [1] 1.322876se(x)#> [1] 1.322876# all return NA if missing values are not removed x2 <- c(x,NA) sd(x2)/sqrt(length(x2))#> [1] NA# Better if missing values are removed se(x2,na.rm=FALSE)#> [1] NAsd(x2,na.rm=TRUE)/sqrt(length(x2[complete.cases(x2)]))#> [1] 1.322876se(x2)#> [1] 1.322876