12.07.2015 Views

R dummies

R dummies

R dummies

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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

You can let the whiskers always extend to the minimum and the maximumby setting the range argument of the boxplot() function to 0.Extracting the data from the plotsThe hist() and boxplot() functions have another incredibly nice feature:You can get access to all the information R uses to plot the histogram or boxplot and use it in further calculations. Getting that information is as easy asassigning the output of the function to an object. For example, you get theinformation on the breaks, counts, and density in a histogram like this:> mpghist mpgbox n text(1:n, mpgbox$stats[1,], + paste(‘n =’,mpgbox$n), + pos=1)With this code, you add a text value under the lower whisker. The x-coordinates 1 through n coincide with the middle of each box. You get the y-coordinates from the stats element in the mpgbox object, which tells youwhere the lower whisker is. The argument pos=1 in the text function placesthe text under the coordinates. You can try playing around with it yourself.While you’re at it, check Chapter 16 for some more tips on manipulatingplots.Tracking correlations

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

Saved successfully!

Ooh no, something went wrong!