Want to keep learning?

This content is taken from the Purdue University & The Center for Science of Information's online course, Introduction to R for Data Science. Join the course to learn more.

Skip to 0 minutes and 8 seconds I wanna extend the example that I just did, where we were looking at the expected arrival delay on each day. And restricting the flights that were arriving to Indianapolis, okay? We can extend that example, that the destination airport is IND, and that the to now specify is ORD, which is O’Hare. There’s a lot of flights like that, okay? So, if I could look at the head of this vector, I just see that this vector contains trues and falses. Similarly, I could go look at another vector that tells me if the origin is O’hare, another vector of trues and falses. One thing I can do is I can go put those together with an ampersand.

Skip to 1 minute and 1 second Let’s go get rid of all our parentheses. You can keep the parenthesie in there if you want to. But this is a vector that identifies the flights, which have IND as the Dest and have ORD as the Origin. It is a vector of 7 million TRUE’s and FALSE’s. We can go take a look at the head of that vector. Again, trues and falses. You can take a look at the length of that vector, 7 million. And if you like, so that you don’t have to put all of that long string into your query above, you can even go save this. Let’s say we call ORD to IND. You can call it anything you want.

Skip to 1 minute and 45 seconds So now I’m gonna go take the code we had before. Say we find the expected arrival delay for flights from ORD to IND, categorized according to the day. So I’m no longer just gonna look for flights that have Indy as the destination. Gonna put in there whether the flight was from O’Hare to Indy or not. And if the flight was from O’Hare to Indy, we count it. And if it wasn’t, we don’t count it. There you go. So for instance, on December 23rd, there must have been some long kind of delays there. Because you had a three hour delay, and on February 12th, 142 minutes delay on average, all right?

Skip to 2 minutes and 29 seconds Were there’s some days in which the expected arrival time was negative, in which you even expected to arrive early? There sure were. Can insert [LAUGH] lots and lots and lots and questions with these t apply functions. It’s good to be practicing. I hope you’re practicing as we’re going through some of these examples. And just trying some things and sort of doing some kind of checks to make sure that you’re getting reasonable results, right? And I’m not surprised at all that the longest expected arrival delay was right in the dead of the Winter. And there may have been very bad weather that day.

Skip to 3 minutes and 3 seconds That’s not entirely surprising, that that’s gonna happen at the end of the year when there could be snow or there could be bad weather.

Arrival Delays by Flight Path

Share this video:

This video is from the free online course:

Introduction to R for Data Science

Purdue University