-
Notifications
You must be signed in to change notification settings - Fork 4
/
Measures of dispersion.R
49 lines (28 loc) · 1.38 KB
/
Measures of dispersion.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
##04/02/2019
#Computation of measures of dispersion/spread using R
#CIAT data and research methods project
#Prepared by Rachael Mburu & Fridah Nyakundi
sd(airquality$Temp)#standard deviation of Temp variable
var(airquality$Temp)#Variance of Temp variable
#Loading package DescTools
library(DescTools)
MeanAD(airquality$Temp,mean)#Mean absolute deviation of Temp variable
MeanAD(airquality$Temp,median)#Median absolute deviation of Temp variable
max(airquality$Temp)#Maximum value of a variable
min(airquality$Temp)#Minimum value of a variable
range(airquality$Temp)#Range of a variable
quantile(airquality$Temp)#Computing quartiles
quantile(airquality$Temp,c(0.25,0.3,0.5))#Computing percentiles using specific percentage ratios.
IQR(airquality$Temp)#Computing the interquartile range of a column.
#loading package moments
library(moments)
skewness(airquality$Temp)#Computing skewness of a variable
kurtosis(airquality$Temp)#Computing kurtosis of a variable
#Covariance calculation sing varous methods
cov(airquality$Wind,airquality$Temp,method = "pearson")
cov(airquality$Wind,airquality$Temp,method = "spearman")
cov(airquality$Wind,airquality$Temp,method = "kendall")
cor(airquality$Wind,airquality$Temp,method = "pearson")
cor(airquality$Wind,airquality$Temp,method = "spearman")
cor(airquality$Wind,airquality$Temp,method = "kendall")
#End.