Learn R Programming

muStat (version 1.7.0)

stdev: Standard Deviation

Description

stdev computes the standard deviation of the values in x. If na.rm is TRUE then missing values are removed before computation proceeds. If x is a matrix or a data frame, a vector of the standard deviation of the columns is returned. If unbiased is TRUE then the sample standard deviation is returned, else the population standard deviation is returned.

Usage

stdev(x, na.rm, unbiased)

Arguments

x
a numeric vector, matrix or data frame
na.rm
logical value indicating if missing values should be removed.
unbiased
whether to return biased or unbiased standard deviation

Value

Standard deviation of x.

See Also

sd, var

Examples

Run this code
x <- c(1, 4, NA, 0, 5)
stdev(x, na.rm=TRUE, unbiased=TRUE)
# [1] 2.380476
stdev(x, na.rm=TRUE, unbiased=FALSE)
# [1] 1.904381

Run the code above in your browser using DataLab