O'Reilly logo

R Data Analysis Cookbook - Second Edition by Kuntal Ganguly

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Finding other measures

There are also other measures for data analysis that aren't found in str() and summary(). Many of them are in base packages, but some packages need to be installed for more unusual measures:

> install.packages(c("modeest","raster","moments"))> library(modeest) #For mfv()> library(raster)  #For quantile() and cv()> library(moments) #For skewness() and kurtosis()

Here are some relevant functions:

Center measures:

> mean(auto$mpg)[1] 23.51457> median(auto$mpg)[1] 23> mfv(auto$mpg)[1] 13> quantile(auto$mpg)  0% 25% 50% 75% 100%  9.0 17.5 23.0 29.0 46.6 

The mfv() function calculates the most frequent value or modes found in a vector. The 50 percent quantile is the same as the median.

Spread measures:

> sd(auto$mpg)[1] 7.815984 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required