Missing Values

How many missing values are in the Ozone column of this data frame?

I want to calculate the number of missing values in a column without having to count them by hand. I’m not sure how to subset only one column of data.

I try this:


It gives me 153 values. This is the number of rows in the data matrix. But, I’m not sure which columns are represented here.

I try this:


And while it seems to print all rows of just the first column and displays the number of missing values, I would have to count them by hand. I want to code a counter to do this for me. There is no mention in the Coursera lecture notes about how to count the number of occurrences. I try a Google search for “R count number of missing values in column” and this was helpful:

[1] http://forums.psy.ed.ac.uk/R/P01582/essential-10/

I try this and it seems to work:


The closest multiple choice option on the quiz is 43. I select this, but get the answer wrong.

Question Explanation

The `is.na’ function can be used to test for missing values.

I’ve already used this, but clearly in the wrong way. So. Let’s try again.



This is the correct answer.

About Lisa Johnson

PhD candidate at UC Davis in Molecular, Cellular, and Integrative Physiology
This entry was posted in Coursera, R. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s