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

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

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

Multivariate data 115Figure 4.4 Scatterplot matrix of fourvariables from babies■ Example 4.5: Accessing a data frame with logical vectors The data set ewr (<strong>Using</strong>R)contains the taxi-in and taxi-out times at Newark Liberty airport. In Example 4.2 wenoted that it would be nice to break up the data based on the variable inorout. We do thisby extracting just those rows that have an inorout value of in (or out). Noting thatcolumns 3 through 10 are <strong>for</strong> theairlines, we can construct the side-by-side boxplots with these commands:> attach(ewr)> boxplot(ewr[inorout == "in", 3:10], main="Taxi in")> boxplot(ewr[inorout == "out", 3:10], main="Taxi out")> detach(ewr)Figure 4.5 Taxi in and out times byairlineThe “rows” argument to the ewr data frame is a logical vector of the correct length.From Figure 4.5, as expected, we see that the airlines have less spread when taxiing inand that the taxi-in times are much shorter than the out times, as there is no takeoff queueto go through.

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

Saved successfully!

Ooh no, something went wrong!