12.07.2015 Views

R dummies

R dummies

R dummies

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

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

and some large islands on Earth.First, create a subset of the ten largest islands in this dataset. There are manyways of doing this, but the following line of code sorts islands in decreasing orderand then uses the head() function to retrieve only the first ten elements:> large.islands plot(large.islands, main=”Land area of continents and islands”,+ ylab=”Land area in square miles”)> text(large.islands, labels=names(large.islands), adj=c(0.5, 1))You can see the results in Figure 16-1. How does this work? The first linecreates the basic plot with plot() and adds a main title and y-axis label. Thesecond line adds text labels with the text() function. In the next section, you getto know each of these functions in more detail.Figure 16-1: A plot with labels, main title, and text.Adding points and lines to a plotTo illustrate some different plot options and types, we use the built-in datasetfaithful. This is a data frame with observations of the eruptions of the Old Faithfulgeyser in Yellowstone National Park in the United States.

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

Saved successfully!

Ooh no, something went wrong!