University of Minnesota, Twin Cities School of Statistics Stat 3011 Rweb Textbook (Wild and Seber)
unemploy, those for which the variable
grouphas the value
"eec". This is documented on the R on-line help for square brackets and relational operators. To see that these are indeed the data you are to plot, look at the data file unemploy.txt.
method="stack"is necessary if the numbers being plotted are not all different.
stemfunction is necessary so that R will draw the same stem-and-leaf plot as in the textbook. This is documented on the R on-line help for stem.
There is no way to tell exactly what any particular value of the
scale argument does. You just have to experiment until
you get a plot that you like.
length, those for which the variable
genderhas the value
"female". This is just like the dot plot example. To see that these are indeed the data you are to plot, look at the data file coyote.txt.
histfunction is necessary so that R will draw the same histogram as in the textbook. This is documented on the R on-line help for hist.
There is no reason to prefer the histogram you get with
over the default behavior
right=FALSE. Thus there is no reason
to use this argument if you don't want to. We only used it to match the
illustration in the textbook.
summarycalculates the "five number summary" (actually six numbers), described on pp. 61-69 of Wild and Seber. Some of the individual numbers in the "five number summary" are calculated by the following four lines
meancalculates the mean.
mediancalculates the median.
quantilefunction calculates arbitrary quantiles (p. 244 ff. in Wild and Seber).
quantile(x, 0.25)calculates the lower quartile (also called the 0.25 quantile or the 25th percentile) of the variable
quantile(x, 0.75)calculates the lower quartile (also called the 0.75 quantile or the 75th percentile) of the variable
sdcalculates the standard deviation.
IQRcalculates the interquartile range (IQR).
x <- c(1, 2, 2, 5, 8, 8, 11, 12, 14)inputs the data for this problem (we just type it in rather than read it from some file on the web). The symbol
<-is the R assignment operator. The function
c"collects" a bunch of numbers into one data vector.
summarycommand is explained in the numerical summaries example.
fred <- c(1, 2, 2, 5, 8, 8, 11, 12, 14) summary(fred)Does exactly the same thing as the example.
Note that upper and lower case are different, that is,
Fred with a capital "F" is a different variable.
names(freq) <- nstrataassociates the names of the strata with the frequencies. The symbol
<-is the R assignment operator.
barplotcommand draws the barplot. This is documented on the R on-line help for barplot.