# Calculate Standard Error in R

**R – Fluent Programming**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

The ** standard error** (

**) of a statistic is the**

*SE***of its sampling distribution or an estimate of that**

*standard deviation***. The standard error is calculated by**

*standard deviation***dividing the standard deviation by the square root of the number of sample data**.

The formula for calculating Standard Deviation in the Mathematics world is

standard error= standard deviation/squareroot(n)

**SE**= standard error of the sample**σ**= sample standard deviation**n**= number of samples

In this tutorial, we will look at how to Calculate Standard Error in R with examples.

## How to Calculate Standard Error in R?

We can calculate Standard Error in three ways in the R language, as shown below.

### Using sd() method

The ** sd()** method takes a numeric vector as input and computes the standard deviation.

> std <- function(x) sd(x)/sqrt(length(x)) > std(c(1,2,3,4)) [1] 0.6454972

### Using the standard error formula

We can use the standard error formula and calculate the standard error manually as shown below.

**Syntax: sqrt(sum((a-mean(a))^2/(length(a)-1)))/sqrt(length(a))**

**where**

- data is the input data
- sqrt function is to find the square root
- sum is used to find the sum of elements in the data
- mean is the function used to find the mean of the data
- length is the function used to return the length of the data

# consider a vector with 10 elements a <- c(1,2,3,4) # calculate standard error print(sqrt(sum((a - mean(a)) ^ 2/(length(a) - 1))) /sqrt(length(a))) [1] 0.6454972

### Using std.error() method from **plotrix**

We can import the plotrix library and use the std.error() method to calculate the standard error.

# import plotrix package library("plotrix") # vector data a <- c(1,2,3,4) # calculate standard error using builtin function print(std.error(a)) [1] 0.6454972

**leave a comment**for the author, please follow the link and comment on their blog:

**R – Fluent Programming**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.