The Art of R Programming

(WallPaper) #1
We can also plot a histogram of the data:

> hist(Nile)

A window pops up with the histogram in it, as shown in Figure 1-1. This
graph is bare-bones simple, but R has all kinds of optional bells and whistles
for plotting. For instance, you can change the number of bins by specify-
ing thebreaksvariable. The callhist(z,breaks=12)would draw a histogram
of the data setzwith 12 bins. You can also create nicer labels, make use of
color, and make many other changes to create a more informative and eye-
appealing graph. When you become more familiar with R, you’ll be able to
construct complex, rich color graphics of striking beauty.

Figure 1-1: Nile data, plain presentation

Well, that’s the end of our first, five-minute introduction to R. Quit R
by calling theq()function (or alternatively by pressingCTRL-D in Linux or
CMD-D on a Mac):

> q()
Save workspace image? [y/n/c]: n

6 Chapter 1

Free download pdf