Contact FutureLearn for Support
Skip main navigation
We use cookies to give you a better experience, if that’s ok you can close this message and carry on browsing. For more info read our cookies policy.
We use cookies to give you a better experience. Carry on browsing if you're happy with this, or read our cookies policy for more information.

Skip to 0 minutes and 13 secondsLet's continue with that example. What I'm gonna look at now, is the total number of flights month by month, just from Indy. Here are all the flights, month by month, from Indianapolis Airport.

Skip to 0 minutes and 26 secondsAnd to do that, I could put in a 1:12.

Skip to 0 minutes and 32 secondsOr another way of doing that is don't put anything for the columns. You still gotta put a comma before how many columns, but if you don't tell it which ones, it'll assume you want all of them. Okay, same effect, just leave the column specification blank, but make sure to put a comma between the rows and the columns. That's one of the biggest mistakes I see students, and even myself do. Is just forgetting to put that comma there between which rows I want and which columns I want. If you're gonna leave the columns blank you've still got to put a comma. You don't put a comma, it's going to think you just want to specify in one dimension.

Skip to 1 minute and 11 secondsBut you've got to tell which rows and which columns or leave one or the other blank.

Skip to 1 minute and 17 secondsWhat about Chicago?

Skip to 1 minute and 21 secondsIf you want Chicago O'Hare, could do this, right? Just change the IND to ORD. And now what about both?

Skip to 1 minute and 35 secondsIf you want them both at once in here.

Skip to 1 minute and 39 secondsI can go put IND and ORD. You see I'm gonna get a matrix back.

Skip to 1 minute and 51 secondsWe can check that the result is a matrix. I think I told you that all the time I'm putting a class around the things that I wanna check.

Skip to 2 minutes and 0 secondsI'll truncate that line so you can see it a little more easily. But it should tell me that I got a matrix back. Indeed, I did.

Skip to 2 minutes and 9 secondsHow big is the matrix? It should be 2 by 12. Let's check. Instead of class, we just ask it for the dimension. You notice I highlight both the rows when I wanna run my command there, indeed, it's a 2 by 12.

Leaving a Specification Blank

Can you create a table with 3 rows and 12 columns, showing the monthly counts for flights departing from ATL, ORD, and DFW?

Comment below.

Share this video:

This video is from the free online course:

Introduction to R for Data Science

Purdue University