3.5

Purdue University

Skip to 0 minutes and 12 secondsOne thing I wanna point out and emphasize is, I don't expect that you know all of these commands right off the bat. I expect as we're learning together that you are playing with some of these ideas that we're using. Trying some things, making plenty of mistakes, I certainly made lots and lots of mistakes as I was learning R. But I think learning in hands on ways is really effective way to kind of master these ideas. Let's take another look at what we just learned.

Skip to 0 minutes and 43 secondsI've got this vector called most popular there. So this is a little bit a review. Here's the vector, the ten most popular airports.

Skip to 0 minutes and 56 secondsI claimed that you could go and look at the origin of each of the flights and see whether it was in the spectrum of most popular or not. Now this is gonna give you a vector of 7 million trues and falses, it's just too many to look at. So let's go look at a few at a time. For instance, if I wanna look at the first, I don't know, let's say 20 of the origins of the flights. There they are IAD, IAD, IND, or lots of them from IND, then one from ISP. I can go see how many of those were amongst the most popular flights.

Skip to 1 minute and 38 secondsOkay, but I accidentally loaded all of them, I tried to load 7 million entries, okay? You see that I make mistakes as well. I don't want all 7 million of the entries. What I want to do is I want to go look at the first 20 of these and I've got to put parenthesis on it, okay? So none of these first 20 origins are amongst the most popular of the airports or amongst the most popular 10 of them. But if we go look at the first 100 of them, there's the first 100 of the origins. Are any of these amongst the ten most popular, sure they are.

Skip to 2 minutes and 14 secondsLook the last couple of rows of them, and indeed those last couple of rows correspond to LAS. Was LAS among the most popular of the airports? It sure was. It was the 8th most popular amongst these 10 really popular airports. I just hope that you're going through and kinda playing with the commands as we work together as we're learning things. I'm certainly not expecting anyone will know how all of these things behave right off the bat. I'm encouraging you to tinkle with these things, to check things, to see what you are working with. To keep your eye on your data window up here, and see how big your different data structures are.

Skip to 2 minutes and 54 secondsTo use things they often, like for instance, the dimension of an object. It is good frequently check things like, for instance, the dimension of a data frame, Or how about length of most popular? That ought to be ten right, cause we've got ten airport codes in there. Length of a vector, I told you the length of a vector is really important when you're doing T applied functions. What about class of a vector, see what kind of data's stored inside there.

Skip to 3 minutes and 34 secondsIn this case, you get character because remember, most popular contains not only ten elements. But each of the elements is some characters that describe the airport code.

Skip to 3 minutes and 46 secondsAll of these things are helpful to be doing as you're learning, as you're working through what some of these commands mean. I just encourage you to be doing them on your own and practising in between our sessions, asking yourself questions, maybe finding another learner that you can be learning alongside. It's a learning process, sometimes it's humbling. And there will certainly be mistakes, but R is really forgiving, because you don't have to compile your code. You don't have to have an entire file of code that works all at once. It's okay to run one line at a time and see what happens and make some mistakes and start again and. It's a learning process and I hope it's enjoyable for you.

Tools for Verifying

In this video, Dr. Mark Ward shows how easy it is to make mistakes in R. Make a comment below about what mistakes you are finding yourself making in R and give tips and tricks to help prevent them.