> stem(

where

> boxplot(

The boxplot function has optional arguments for controlling the page layout of the plot and fine details of the boxes and whiskers in the plot. When you are ready to experiment with them, you can read about these options by calling

> help(boxplot)

Side-by-side boxplots are useful for comparing the distributions of several data vectors. If

> boxplot(

Side by side boxplots of data grouped by levels of a factor can be produced using formula syntax, as in

> boxplot(

where

An optional argument that is sometimes helpful is the logical

> boxplot(

> qqnorm(

> qqline(

The second command above draws a line through the points whose coordinates are the quartiles on each axis. This line helps you assess the straightness of the set of points, and thus the departure from normality of the data.

There is another type of quantile plot for comparing the order statistics from two independent samples to assess whether or not they come from the same distribution. The two samples do not have to be of the same size. If the data from the two samples are the vectors

> qqplot(

The interpretation of this plot is similar to that produced by

A basic, no-frills histogram of a numeric vector

> hist(

There are lots of optional arguments to the

> hist(

To make one with bins (0,2], (2,6], (6,8], (8,10)

> hist(

Notice that the bin widths are not all the same in the last example.

By default, the vertical scale of the bars of an R histogram shows the counts of the data values that fall in each of the class intervals. Histograms are often used as approximations of a density function, and in that role they should be density functions themselves. That is, the sum of the areas of the histogram bars should be 1. This can be accomplished by setting the logical

> hist(

With bins of equal length, the shape of the histogram is the same when

>

This produces a vector of the counts of the various levels of the factor variable

> barplot(

and the pie chart by

> pie(

Optional arguments to

Scatterplots or scatter diagrams are probably encountered more than any other kind of plot in elementary statistics. A scatterplot is just a plot of a finite set of points (x

> plot(

gives you the scatterplot. It is important that the lengths of

> plot(

Sometimes it is more convenient to use formula syntax to create a scatterplot.

> plot(

If either

In order to superimpose the least squares regression line on a scatterplot, you must first calculate the regression coefficients. There are lots of ways of doing this. The most general and useful is with the

>

The argument "data =

> plot(

> abline(coef(

The function

> pairs(

or

> plot(

This is a very good way to look at how several variables interact in pairs. Variables in the data frame that are non-numeric factors are treated as numeric. Thus, pairs involving factors may not tell you anything useful.

Three dimensional scatterplots c

> library(Rcmdr)

It takes a few seconds for the package to be loaded and for a window to

> curve(

For example, the sine function is graphed by

> curve(sin, from=-pi, to=pi)

There are optional arguments for adjusting certain features of the plot. If the plotted function has a simple formula, the formula can be used in place of the name of a function. This eliminates the need to define the function prior to calling

> curve(-2*x^2+1,from=-2,to=2)

plots part of the parabola y = -2x

> curve(-2*x^2+1, add=T)

Notice that the

To copy and paste a plot into another application, such as a Microsoft Word document, right-click in the plot area and from the popup menu select either "Copy as metafile" or "Copy as bitmap". Then you may simply paste it into your other application. To save a plot, right-click again and select "Save as metafile" or "Save as bitmap". These can be converted to jpeg or gif files externally if you like. You may find resolution to be improved by resizing the plot inside R before copying it. The menu also allows you to print the plot to a printer or to pdf format, if you have the right software.