BaşlayınÜcretsiz Başlayın

Finding the problem areas

When you are working with a small list, it might not seem like a lot of work to go through things manually and figure out what element has an issue. But if you have a list with hundreds or thousands of elements, you want to automate that process.

Now you'll look at a situation with a larger list, where you can see how the error message can be useful to check through the entire list for issues.

Bu egzersiz

Foundations of Functional Programming with purrr

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • map() over sw_people and pull out the "height" element.
  • map() over safely() to convert the heights from centimeters into feet.
  • Set quiet = FALSE so that errors are printed.
  • Pipe into transpose(), to print the results first.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Map over sw_people and pull out the height element
height_ft <- map(___ , ___) %>% 
  map(safely(function(___){
    ___ * 0.0328084
  }, quiet = ___)) %>% 
___

# Print your list, the result element, and the error element
height_ft
height_ft[["result"]]
height_ft[["error"]]
Kodu Düzenle ve Çalıştır