> mean(quarters)
[1] 5.583333
> median(quarters)
[1] 5.552
• mode– there is no built in function for finding an object’s mode; however, the
command table(object) creates a frequency table for the object’s elements and the
mode is the element in this table with the greatest frequency
> table(quarters)
5.536 5.539 5.548 5.549 5.551 5.552 5.554 5.62 5.632 5.683 5.684
1 1 1 1 1 2 1 1 1 1 1
• midrange – there is no built in function for reporting the midrange; the command
shown below use the functions for an object’s maximum (max) and minimum (min)
to calculate and print the object’s midrange
[1] 5.61
1
Last Modified January 26, 2007
Measures of Spread
> var(quarters)
[1] 0.003116606
> sd(quarters)
[1] 0.05582657
• standard error of the mean – there is no built in function for reporting the standard
error of the mean; the command shown below use the functions for the object’s
standard deviation (sd) and number of elements (length), as well as the mathematical
function for finding a square root (sqrt) to calculate and print the object’s standard
error of the mean
[1] 0.01611574
• range – there is no built in function for reporting the range; the command shown
below use the functions for an object’s maximum (max) and minimum (min)
elements to calculate and print the object’s range
[1] 0.148
• IQR(object) – provides the object’s interquartile range; note – this value may differ
slightly from that provided by other programs because there is no single accepted
definition for FU and FL
> IQR(quarters)
[1] 0.07425
2
Last Modified January 26, 2007
• skew(object) – provides the skewness for an object; this function is not included in R,
but is available from the file “skew&kurt.RData,” which is available on the course’s
I-drive account.
> skew(quarters)
[1] 0.8508155
> kurt(quarters)
[1] -1.075001
> hist(quarters)
3
Last Modified January 26, 2007
> boxplot(quarters)