Standard Deviation in R

Standard deviation is a measure of how a set of data is spread around the mean. It is used to understand whether a specific data point is standard and expected or unusual and unexpected. This guide shows you how to calculate standard deviation in R.

Calculating Standard Deviation in R using sd()

R has a built-in function to calculate standard deviation, sd().

Syntax

sd(x)

Here, x is the object like a vector, dataframe or matrix.

Example

#creating vector containing height data
height <- c(171,169,178,181,186,177)
#calculating standard deviation
sd(height)

Output

[1] 6.292853

Leave a Comment