Standard Error in R

Standard error is a statistical measure of the spread of the sample data. It measures how a set of data is spread around the sample mean. While calculating SE involves lots of calculations, R comes with a built-in function to calculate it. This guide will show the calculation of standard error in R.

There are two ways to calculate standard error in R:

Indirectly using the sd() function

Mathematically, standard error can be calculated by dividing the standard deviation of the input vector by the square root of the length of the input vector::

Standard Error = sd/√ n

Here, n denotes the length of the data. sd denotes the standard deviation. To learn how to compute standard Deviation in R, click here.

Syntax to compute standard error in R

To compute standard error in R, use the following syntax.



  1. sd = built-in function to compute standard deviation
  2. sqrt = built-in function to find the square root
  3. length = built-in function to find the length of the data
  4. x = input vector
Derivation of Standard Error Function in R
Comparing mathematical formula and the function in R to calculate the standard error.


Calculate standard error from a vector with six elements.

#creating a vector
height <- c(171,169,178,181,186,177)
#calculating Standard Error


[1] 2.569047

Directly using the std.error() function

std.error() comes from the plotrix package. To install and load the package, run the following code:





  • x = input vector


Calculate standard error from a vector using std.error() function.

#creating a vector
height <- c(171,169,178,181,186,177)
#calculating standard Error


[1] 2.569047

Leave a Comment