Friday, September 11, 2026
Home FEATURED Calculate Mean and Standard deviation in R

Calculate Mean and Standard deviation in R

In R, you can use the mean() function to calculate the mean of a numerical vector, and the sd() function to calculate the standard deviation of a numerical vector. Here is an example:

# Create a numerical vector
x <- c(1, 2, 3, 4, 5)

# Calculate the mean
mean(x)

# Calculate the standard deviation
sd(x)

You can also use the summary() function to get the mean and standard deviation together with other summary statistics of a numerical vector.
There is also a package called psych which has more advanced functionality for calculating descriptive statistics, like describe() function which gives a more detailed summary of the data.

library(psych)
describe(x)

You can install the package by using install.packages("psych") and load the package by using library(psych).

datasagarhttp://www.DataSagar.com
Sagar is multidisciplinary technologist, educator, and entrepreneur based in Nepal. As the founder of Illionso Technologies and Kashi Garden Resort, he operates at the intersection of web architecture, data intelligence, innovation, and digital transformation. From building digital solutions to scaling real-world concepts, his mission is to share knowledge alongside merge emerging as well as disruptive technologies with transformative offline experiences.
RELATED ARTICLES

Meta Muse AI Agent Everything You Need to Know About Features and Privacy

Discover everything about Meta Muse, the new personal AI agent designed to execute goals 24/7. Explore its features, Secure Virtual Machine privacy, token pricing, and the future of autonomous AI.

Nepal Government Approves Software Development Center to Hire 93 IT Specialists – Gov Tech Updates

Nepal is taking a massive step forward in government technology. The administration has formally advanced plans...

Most Popular