LoslegenKostenlos starten

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.

Diese Übung ist Teil des Kurses

<Kurs>Intermediate Functional Programming with purrr</Kurs>
Kurs ansehen

Übungsanweisungen

  • 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.

Interaktive praktische Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# 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(___)
Code bearbeiten und ausführen