var() function in R Language computes the sample variance of a vector. It is the measure of how much value is away from the mean value.
Syntax: var(x)
Parameters:
x : numeric vector
Example 1: Computing variance of a vector
# R program to illustrate # variance of vector # Create example vector x <- c(1, 2, 3, 4, 5, 6, 7) # Apply var function in R var(x) print(x) |
Output:
4.667
Here in the above code, we took an example vector “x1” and calculated its variance.
sd() Function
sd() function is used to compute the standard deviation of given values in R. It is the square root of its variance.
Syntax: sd(x) Parameters: x: numeric vector
Example 1: Computing standard deviation of a vector
# R program to illustrate # standard deviation of vector # Create example vector x2 <- c(1, 2, 3, 4, 5, 6, 7) # Compare with sd function sd(x2) print(x2) |
Output: 2.200
Here in the above code, we took an example vector “x2” and calculated its standard deviation.
Recommended Posts:
- Calculate the Median Absolute Deviation in R Programming - mad() Function
- Compute the Value of F Density in R Programming - df() Function
- Compute the value of Quantile Function over Wilcoxon Rank Sum Distribution in R Programming – qwilcox() Function
- Compute the value of Quantile Function over Wilcoxon Signedrank Distribution in R Programming - qsignrank() Function
- Compute the Natural Logarithm of the Absolute Value of Gamma Function in R Programming - lgamma() Function
- Compute the Logarithmic Derivative of the gamma Function in R Programming - digamma() Function
- Compute Single Order Integral value of a Function in R Programming - integrate() Function
- Compute the value of Quantile Function over Studentized Distribution in R Programming - qtukey() Function
- Compute the Value of Quantile Function over Uniform Distribution in R Programming - qunif() Function
- Compute the Value of Quantile Function over Weibull Distribution in R Programming - qweibull() Function
- Compute the Value of Negative Binomial Quantile Function in R Programming - qnbinom() Function
- Compute the Second Derivative of the Logarithmic value of the gamma Function in R Programming - trigamma() Function
- Compute the Value of Empirical Cumulative Distribution Function in R Programming - ecdf() Function
- Compute the Value of Geometric Quantile Function in R Programming - qgeom() Function
- Compute value of Log Normal Quantile Function in R Programming - qlnorm() Function
- Compute the Value of Poisson Quantile Function in R Programming - qpois() Function
- Compute the value of Cauchy Quantile Function in R Programming - qcauchy() Function
- Compute value of Logistic Quantile Function in R Programming - qlogis() Function
- Compute Density of the Distribution Function in R Programming - dunif() Function
- Compute the Covariance between Two Vectors in R Programming - cov() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

