**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) ` |

*chevron_right*

*filter_none*

**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) ` |

*chevron_right*

*filter_none*

Output:2.200

Here in the above code, we took an example vector “x2” and calculated its standard deviation.

## Recommended Posts:

- Calculate the Average, Variance and Standard Deviation in R Programming
- Compute the Natural Logarithm of the Absolute Value of Gamma Function in R Programming - lgamma() Function
- Compute the Second Derivative of the Logarithmic value of the gamma Function in R Programming - trigamma() 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 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 Negative Binomial Quantile Function in R Programming - qnbinom() Function
- Compute the Value of Empirical Cumulative Distribution Function in R Programming - ecdf() Function
- Compute the value of F Cumulative Distribution Function in R Programming - pf() Function
- Compute the value of Quantile Function over F Distribution in R Programming - qf() Function
- Compute the Value of Quantile Function over Weibull Distribution in R Programming - qweibull() Function
- Compute the value of Quantile Function over Studentized Distribution in R Programming - qtukey() Function
- Compute the value of Quantile Function over Wilcoxon Signedrank Distribution in R Programming - qsignrank() Function
- Compute the value of Quantile Function over Wilcoxon Rank Sum Distribution in R Programming – qwilcox() Function
- Compute Single Order Integral value of a Function in R Programming - integrate() Function
- Compute the Value of Geometric Quantile Function in R Programming - qgeom() Function
- Compute the Value of Quantile Function over Uniform Distribution in R Programming - qunif() Function
- Calculate the Median Absolute Deviation in R Programming - mad() Function
- Performing F-Test in R programming - var.test() Method

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.