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 main navigation

Leaving a Specification Blank

Dr. Mark Ward demonstrates leaving a specification blank.
Let’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.
And to do that, I could put in a 1:12.
Or 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.
But you’ve got to tell which rows and which columns or leave one or the other blank.
What about Chicago?
If you want Chicago O’Hare, could do this, right? Just change the IND to ORD. And now what about both?
If you want them both at once in here.
I can go put IND and ORD. You see I’m gonna get a matrix back.
We 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.
I’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.
How 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.
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.
This article is from the free online

Introduction to R for Data Science

Created by
FutureLearn - Learning For Life

Our purpose is to transform access to education.

We offer a diverse selection of courses from leading universities and cultural institutions from around the world. These are delivered one step at a time, and are accessible on mobile, tablet and desktop, so you can fit learning around your life.

We believe learning should be an enjoyable, social experience, so our courses offer the opportunity to discuss what you’re learning with others as you go, helping you make fresh discoveries and form new ideas.
You can unlock new opportunities with unlimited access to hundreds of online short courses for a year by subscribing to our Unlimited package. Build your knowledge with top universities and organisations.

Learn more about how FutureLearn is transforming access to education