Get startedGet started for free

Count the NA

Now that you have a stricter version of the status code extractor, we'll try it on our list of URLs.

What we want to do here is to see which of the websites from our list return a status code which is not between 200 and 203. To achieve this task, we'll flip the is.na() function, that is to say that instead of returning TRUE if the value is missing, it will return FALSE.

The urls vector and the strict_code() function are available in your workspace. httr and purrr has been loaded for you.

This exercise is part of the course

Intermediate Functional Programming with purrr

View Course

Exercise instructions

  • Run the strict_code() against the vector of urls.

  • Set the names of the results with the set_names() function, using the urls vector.

  • "Flip" the is.na() function by negating its behavior.

  • Use the is_not_na() function on the vector of results.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Map the strict_code function on the urls vector
res <- ___(urls, ___)

# Set the names of the results using the urls vector
res_named <- ___(res, ___)

# Negate the is.na function
is_not_na <- ___(___)

# Run is_not_na on the results
is_not_na(___)
Edit and Run Code