VOOZH about

URL: https://www.geeksforgeeks.org/r-language/compute-variance-and-standard-deviation-of-a-value-in-r-programming-var-and-sd-function/

⇱ Compute Variance and Standard Deviation of a value in R Programming - var() and sd() Function - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Compute Variance and Standard Deviation of a value in R Programming - var() and sd() Function

Last Updated : 15 Jul, 2025
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 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
Output: 2.200
Here in the above code, we took an example vector "x2" and calculated its standard deviation.
Comment

Explore