How to Calculate Descriptive statistics using R – R tutorial

1985
In this post, I will explain how to calculate basic descriptive statistics using R. The following R scripts helps to calculate descriptive statistics such as Mean, Median, Mode, Standard deviation, Standard error of the mean, Five-number summary, quartiles, percentiles, skewness and kurtosis.
Packages used are psych and Desctools
##Descriptive statistics using R##
##Packages used psych and Desctools
##Following commands will install the packages only if they are not already installed
if(!require(psych)){install.packages("psych")}
if(!require(DescTools)){install.packages("DescTools")}
#Load your data here
data("trees") ##loads data inbuilt in dataset package of R which includes Girth, Height and Volume for Black Cherry Trees
##structure of the data frame
str(trees)
##summary
summary(trees)
##mean
mean(trees$Height)
##median
median(trees$Height)
##mode
Mode(trees$Height)
##Standard deviation
sd(trees$Height)
##Standard error of the mean
sd(trees$Height) / sqrt(length(trees$Height))
##Five-number summary, quartiles, percentiles
summary(trees$Height)
##skewness and kurtosis
describe(trees$Height,type=3) #there are 3 options available u can see in package documentation for details
You can find the script and download in Github Descriptive Statistics in R. Share and Subscribe to SAR Publisher via Email for more interesting updates.

 

Previous articleList of SLV Launches by Indian Space Research Organisation (ISRO)
Next articleQuran in Tamil – திருக்-குர்ஆன் தமிழாக்கம்
A.Sulthan, Ph.D.,
Author and Assistant Professor in Finance, Ardent fan of Arsenal FC. Always believe "The only good is knowledge and the only evil is ignorance - Socrates"
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments