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

purrr and scatterplots

Since ggplot() does not accept lists as an input, it can be paired up with purrr to go from a list to a data frame to a ggplot() graph in just a few lines of code.

You will continue to work with the gh_users data for this exercise. You will use a map_*() function to pull out a few of the named elements and transform them into the correct datatype. Then create a scatterplot that compares the user's number of followers to the user's number of public repositories.

Bu egzersiz

Foundations of Functional Programming with purrr

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

Egzersiz talimatları

  • map() over gh_users, use the map_*() function that creates a data frame, with four columns, named "login", "name", "followers" and "public_repos".
  • Pipe that data frame into a scatterplot, where the x axis is followers and y is public_repos.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Create a data frame with four columns
map___(___, `[`, 
       c(___,___,___,___)) %>%
       # Plot followers by public_repos
    ggplot(., 
         aes(x = ___, y = ___)) + 
        # Create scatter plots
        geom____()
Kodu Düzenle ve Çalıştır