A simple example of calculating standard dev:
d <- c(2,4,4,4,5,5,7,9)
sd(d)
yields
[1] 2.13809
but
When I want the population variance or standard deviation (n as denominator), I define these two vectorized functions.
pop.var <- function(x) var(x) * (length(x)-1) / length(x)
pop.sd <- function(x) sqrt(pop.var(x))
BTW, Khan Academy has a good discussion of population and sample standard deviation here.