Consider the number of days absent from a random sample of six
students during a semester: A= {2, 3, 2, 4, 2, 5}
Compute the arithmetic mean, geometric mean, median, and mode
by hand and verify the results using R
Arithmetic Mean:
X=i=1nXin=2+3+2+4+2+56=3
mean(data2$absent)
[1] 3
Geometic Mean:
GMx=Πi=1nX11n=2∙3∙2∙4∙2∙516=2.79816
>gmean <-
prod(data2$absent)^(1/length(data2$absent))
> gmean
[1] 2.798166
Median:
X=12n+1th,
Xi2,2,2,3,4,5,
n=6=126+1th
ranked value=3.5, value=2.5 days absent
>median(data2$absent)
[1] 2.5
Mode: Most frequent value=2
> mode <-
names(table(data2$absent))
[table(data2$absent)==max(table(data2$absent))]
> mode
[1]...