10.07.2015 Views

Using R for Introductory Statistics : John Verzani

Using R for Introductory Statistics : John Verzani

Using R for Introductory Statistics : John Verzani

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Bivariate data 83> plot(height, weight, pch=as.character(gender))> detach(kid.weights)Figure 3.8 Height versus weight <strong>for</strong>kid.weightsFigure 3.8 indicates that weight may be related to the height squared. It certainly does notappear to be a straight-line relationship.Arguments <strong>for</strong> the plot() function The plot() function, and other graphing functionslike hist(), boxplot(), and lines(), take extra arguments that can control portions of thegraphic. Table 3.7 list some of the possible arguments. More details are found on the helppages <strong>for</strong> the individual functions. Most of these arguments are graphics parameters thatmay also be queried and set using par(). The documentation <strong>for</strong> these arguments is foundin the help page <strong>for</strong> par(). (This function is discussed more fully in Appendix D.) Some ofthe arguments, such as main=, xlim=, and xlab=, can be used only with plottingfunctions that set up a plot window (called high-level plotting functions).Table 3.7 Useful arguments <strong>for</strong> plot() and othergraphic functionsmain= Title to put on the graphic.xlab= Label <strong>for</strong> the x-axis. Similarly <strong>for</strong> ylab=.xlim= Specify the x-limits, as in xlim=c(0, 10), <strong>for</strong> the interval [0, 10].Similar argument <strong>for</strong> the y-axis is ylim=.type= Type of plot to make. Use "p" <strong>for</strong> points (the default), "1" (ell not one) <strong>for</strong> lines, and "h" <strong>for</strong>vertical lines.bty= Type of box to draw. Use "l" <strong>for</strong> “L”-shaped, default is "o", which is “O”-shaped. Details in?par.pch= The style of point that is plotted. This can be a number or a single character. Numbersbetween a and 25 give different symbols. The command plot (0:25, pch=0:25) will showthose possible.cex= Magnification factor. Default is 1.lty= When lines are plotted, specifies the type of line to be drawn. Different numbers correspondto different dash combinations. (See ?par <strong>for</strong> full details.)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!