sd

Basics

sd is a function that calculates the standard deviation of a vector of values. sd(x) is equivalent to sqrt(var(x))


Examples

How do I get the standard deviation of the values in a vector?

Click to see solution
weights <- c(147, 280, 180, 190, 145)
sd(weights)
[1] 49.114560

How do I get the standard deviation of the values in a vector when some of the values are: NA, NaN?

Click to see solution

See our mean page for information on na.rm.

weight <- (c(147, NA, 280, 180, 190, 145, NaN), na.rm=TRUE)
sd(weights)
[1] 49.114560