R SD SE Calculations


sd() function calculates the standard deviation.

sd(x, na.rm=FALSE)

x: numeric vector
na.rm: missing values should be removed or not


> x <- c(1,2.3,2,3,4,8,12,43,-4,-1)
> r <- sd(x)
> r
[1] 13.39602

The standard error equals sd/√n:
> x <- c(1,2.3,2,3,4,8,12,43,-4,-1)
> se <- sd(x)/sqrt(length(x))
> se
[1] 4.236195

Calculate the SD of data frame (matrix):
>BOD       #R Biochemical Oxygen Demand database
  Time demand
1    1    8.3
2    2   10.3
3    3   19.0
4    4   16.0
5    5   15.6
6    7   19.8
> apply(BOD,2,sd)
    Time   demand 
2.160247 4.630623