How to usesd() function with length function in R Language
Here we are going to use sd() function which will calculate the standard deviation and then the length() function to find the total number of observation.
Syntax: sd(data)/sqrt(length((data)))
Example: R program to calculate a standard error from a set of 10 values in a vector
R
# consider a vector with 10 elements a < - c (179, 160, 136, 227, 123, 23, 45, 67, 1, 234) # calculate standard error print ( sd (a)/ sqrt ( length ((a)))) |
Output:
[1] 26.20274
Calculate Standard Error in R
In this article, we are going to see how to calculate standard error in R Programming Language.
Mathematically we can calculate standard error by using the formula:
standard deviation/squareroot(n)
In R Language, we can calculate in these ways:
- Using sd() function with length function
- By using the standard error formula.
- Using plotrix package.