Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Data Visualization
  • Statistics in R
  • Machine Learning in R
  • Data Science in R
  • Packages in R
  • Data Types
  • String
  • Array
  • Vector
  • Lists
  • Matrices
  • Oops in R
Open In App
Next Article:
Compute value of Quantile Chi Square Density in R Programming - qchisq() Function
Next article icon

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

Last Updated : 26 May, 2020
Comments
Improve
Suggest changes
Like Article
Like
Report
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 Python3
# 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 Python3
# 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.

Next Article
Compute value of Quantile Chi Square Density in R Programming - qchisq() Function
author
akhilsharma870
Improve
Article Tags :
  • Programming Language
  • R Language
  • R Functions

Similar Reads

  • Compute the Value of F Density in R Programming - df() Function
    df() function in R Language is used to compute the density of F Distribution over a sequence of numeric values. It also plots a density graph for F Distribution. Syntax: df(x, df1, df2) Parameters: x: Numeric Vector df: Degree of Freedom Example 1: # R Program to compute # F Density # Creating a seq
    1 min read
  • Compute value of Quantile Chi Square Density in R Programming - qchisq() Function
    qchisq() function in R Language is used to compute value of chi square quantile function. It creates a quantile function plot for chi square distribution. Syntax: qchisq(vec, df) Parameters: vec: Vector of x-values df: Degree of Freedom Example 1: # R program to compute # Quantile Chi Square density
    1 min read
  • Compute the value of CDF on Uniform Distribution in R Programming - punif() Function
    In R programming, punif() function is used to compute the value of Cumulative Distribution Function(CDF). Syntax: punif(q, min = 0, max = 1, lower.tail = TRUE, log.p = FALSE) Parameters: q: represents vector of quantiles min, max: represents lower and upper limits of the distribution lower.tail: rep
    1 min read
  • Compute the value of CDF over Studentized Range Distribution in R Programming - ptukey() Function
    ptukey() function in R Language is used to compute the value of Cumulative Distribution Function(CDF) over Studentized Range for a sequence of numeric values. Syntax: ptukey(x, nmeans, df) Parameters: x: Numeric Vector nmeans: Number of means df: Degree of Freedom Example 1: # R Program to compute t
    1 min read
  • Compute value of Log Normal Quantile Function in R Programming - qlnorm() Function
    qlnorm() function in R Language is used to compute the value of log normal quantile function. It also creates a plot of the quantile function of log normal distribution. Syntax: qlnorm(vec) Parameters: vec: x-values for normal density Example 1: # R program to compute value of # log normal quantile
    1 min read
  • Condense Column Values of a Data Frame in R Programming - summarise() Function
    summarise() function in R Language is used to condense various values of column of a data frame to one value. Syntax: summarise(x, expr) Parameters: x: Data Frame expr: Operation to condense data Example 1: # R program to condense data # of a data frame # Loading library library(dplyr) # Create a da
    1 min read
  • Compute Chi Square Density in R Programming - dchisq() Function
    dchisq() function in R Language is used to compute chi square density for a vector of elements. It also creates a density plot for chi square distribution. Syntax: dchisq(vec, df) Parameters: vec: Vector of x-values df: Degree of Freedom Example 1: # R program to compute # Chi Square Density # Creat
    1 min read
  • Create Quantiles of a Data Set in R Programming - quantile() Function
    quantile() function in R Language is used to create sample quantiles within a data set with probability[0, 1]. Such as first quantile is at 0.25[25%], second is at 0.50[50%], and third is at 0.75[75%]. Syntax: quantile(x) Parameters: x: Data set Example 1: # R program to create # quantiles of a data
    1 min read
  • Compute the Value of Negative Binomial Quantile Function in R Programming - qnbinom() Function
    qnbinom() function in R Language is used to compute the value of negative binomial quantile function. It also creates a density plot of the negative binomial quantile function. Syntax: qnbinom(vec, size, prob) Parameters: vec: x-values for binomial density size: Number of trials prob: Probability Ex
    1 min read
  • Generate a set of Sample data from a Data set in R Programming - sample() Function
    sample() function in R Language creates random sample based on the parameters provided in the function call. It takes either a vector or a positive integer as the object in the function parameter. Syntax: sample(x, size, replace) Parameters: x: indicates either vector or a positive integer or data f
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences