Thursday, 21 May 2015

Measure of central tendency and measure of dispersion using R console:

> age1=scan()      [enter data by variable age1]
1: 20
2: 24
3: 19
4: 24
5: 18
6: 19
7: 24
8: 22
9: 23
10: 19
11: 19
12: 24
13: 2
14: 21
15: 22
16: 23
17: 24
18: 21
19: 25
20: 23
21:
Read 20 items
> mean(age1)      [to find mean]
[1] 20.8
> median(age1)    [to find median]
[1] 22
> summary(age1)    [to find min., 1st, 3rd quartile, mean, median, max. at a time]
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
    2.0    19.0    22.0    20.8    24.0    25.0
> quantile(age1)                                        [to find n percentile]
  0%  25%  50%  75% 100%
   2   19   22   24   25
> IQR(age1)   [to find inter quartile range]
[1] 5
> var(age1)     [to find variance]
[1] 24.27368
> sd(age1)      [to find S.D. ]
[1] 4.926833
> boxplot(age1, lables=T)    [to draw boxplot of data]

No comments:

Post a Comment