Thursday, September 21, 2023
HomeFEATUREDCalculate 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

# Calculate the standard deviation

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.


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

The author of this blog post is a technology fellow, an IT entrepreneur, and Educator in Kathmandu Nepal. With his keen interest in Data Science and Business Intelligence, he writes on random topics occasionally in the DataSagar blog.
- Advertisment -

Most Popular