purrr Vignette Ext dcraig

Recap

      Purrr has been introduced by Glen(my classmate) with some of its basic, but useful, functions that will introduce you to the package. We will be recapping his work int eh first section, if you are recently coming off of his vignette, feel free to start at the “Extension” section. It is a great starting place. The hope of this vignette is to expand and build atop of what Glen has shown us thus far. To ensure things are seamless, I’ve downloaded Glen’s Vignette and re-ran all of his code to put the same variables into my environment. If you are viewing this document without the first, please download and run Glen’s vignette first or a lot of code is going to break.
      Purrr’s purpose as a package is to provide a uniform syntax and function structure to iterate commonly used or user created functions across multiple objects and elements.

When Should One Use Purrr?

      A concrete example of Purrr is applying functions to lists, even nested lists, of dataframes or other objects/elements matching the user provided criteria. Think of big bulky objects such as a nested list with 500 different dataframes that have common features. Let’s say out of the 500, only 200 have the features you’re interested in and want to single those out and start tweaking them. Those 500 dataframes might actually even be lists themselves with their own nested objects. Purrr is great at dealing with this scenario. If you’re familiar with dplyr, you can think of dplyr as… pliers for intricate tweaking and purrr as a robust engine pumping through material (quite possibly an inspiriation of the name from the phrase “hearing that engine purr”).
      You may find commonalities between Purr and other packages like Base R, dplyr, or other tidyverse packages. Purrr performs a hair slower than Base R, but in exchange offers thematically and gramatically similar coding syntax and structure as compared to Base R. It also works with piping in the tidyverse. This stackexchange post goes over an example of this comparing Purrr’s map() and Base R’s lapply() in regards to speed and also points out some differences in grammar. It’s a quick skim.

Previous Purrr Commands Covered:

  1. map_chr(): applies a user-provided function to a user-designated object and returns a character vector
      We used this to rename some columns using a created function to remove spaces, brackets, and parenthesis.
fix_col_names <- function(s){
    s <- gsub("[()]", "", tolower(s))
    s <- gsub(" ", "_", s)
    s
}

col_names <- map_chr(colnames(disney_movies_df), fix_col_names)
  1. map_dfr(): applies a user-provided function to a user-designated object and returns a data frame
      Below we applied the class function from Base R, which tells us the class of the item we pass it, using map_dfr, which will apply class to each element and return a data frame of those elements.
paged_table(data.frame(map_dfr(disney_movies_df, class)))
  1. map_int(): same as the previous but returns an integer vector
      Although it’s a bit redundant, since map_int automatically converts its data to integer and the dataset was already an integer vector, its a good example of the structure and shows how you can deal with potential vectors with mixed data types that should all just be integer class.
disney_movies_df$running_time_int <- map_int(disney_movies_df$running_time_int,
                                             as.integer)
disney_movies_df$imdb <- map_dbl(disney_movies_df$imdb, as.double)

map_dbl(): same as previous but returns a double vector

      The first example is the same type of work as before, but I really liked the 2nd usage of map_dbl below as it shows how much work one simple line of code can complete with purrr. In that example, we used purrr to create double vectors of the columns of interest to create a statistical summary and wrap them up in a map_dfr() to create a slick dataframe for presentation.
fix_percentage <- function(s){
    s <- gsub("%", "", s)
    s <- as.double(as.integer(s) / 100)
    s
}
disney_movies_df$rotten_tomatoes <- map_dbl(disney_movies_df$rotten_tomatoes, fix_percentage)
cols <- c("running_time_int", "budget_float_in_millions",
          "box_office_float_in_millions", "imdb", "metascore",
          "rotten_tomatoes")
p1 <- map_dbl(disney_movies_df[, cols], min, na.rm = TRUE)
p2 <- map_dbl(disney_movies_df[, cols], mean, na.rm = TRUE)
p3 <- map_dbl(disney_movies_df[, cols], max, na.rm = TRUE)
disney_movies_summary <- as.data.frame(map_dfr(list(p1, p2, p3),
                                               round, digits = 6))

map(): apply function to each element of a list or vector and returns a list

imdb_hist <- function(dat){
    ggplot(dat, aes(x = imdb)) +
    geom_histogram(binwidth = 0.5, fill="lightblue") + 
    xlim(0,10) + 
    ylim(0,20) +
    labs(x = "imdb score", y = "movie count") + 
    theme(plot.margin = unit(c(1.5, 0.5, 0, 0), "lines"),
          panel.grid.major = element_blank(),
          panel.grid.minor = element_blank(),
          panel.background = element_blank(),
          axis.line = element_line(colour = "darkblue"))
}

by_decade <- by_decade %>%
    filter(!is.na(release_decade)) %>%
    mutate(plot = map(data, imdb_hist))

Extenstion

      Glenn gives a strong opening to purr package that illustrates the basic concept of iteration by using the map functions. From here, this vignette is going to focus on:
  1. Using walk(), map2(),pmap(),imap() to work with multiple objects
  2. Using filter commands & working with lists

The Cheatsheet

      The cheatsheet is going to be our guide here. I’d recommend pulling it up and following along from this link. If you take a look at it, it’s pretty well organized. The entire first page represents similar functions and are organized by which scenarios they’re used in, ie. one dataframe, a list, two lists, etc.
      The first portion we will highlight are shortcuts that we will be attempting to use as often as we can throughout the vignette. We are leaving this here as a referece, don’t force yourself to understand the picture of shortcuts, keep moving through the vignette. As a summary, in purrr’s functions we can initiate inline custom functions by using the tilda ‘~’ to tell the function an in-line custom function is coming, and .x, .y, or .z as placeholders that represent the actual objects we’re working with. This is useful when we are performing work like adding elements from .x to .y or the like.

Working with Multiple Objects

      Purrr’s focus is manipulating large objects iteratively. Let’s showcase this by using some functions like:
  • walk(): processes a function iteratively but returns output invisibly, useful for when you need to perform a process on an object, and then pipe it to the next function
  • imap(): apply a function to each element, and its index (useful)
  • map2(): same as map, but allows for processing across pairs of elements
  • pmap(): same as map2, but allows for processing across more than two vectors

walk():processes a function iteratively but returns output invisibly

      Walk is useful when a process needs to happen without returning its output. One specific method is a slight re-creation of Glen’s work using cowplot’s plot_grid. In Glen’s example, he had 10 or so plots which could all fit well inside cowplot’s grid. We can perform something similar with walk, but without condensing the graphs when you want to look at 2 - 3 graphs. This could be useful if you have an object with hundreds of plots, but you know you only need to see specific numbers and are piping.
library(dplyr)

plotsOfInterest <- by_decade$plot[c(2,4,8)]

plotsOfInterest %>%
  walk(print)

imap(): apply a function to each element and its index (useful for tracking indexes whilst changing objects)

      Let’s say for instance that our Disney movies were handed to us in a tibble of dataframes by each decade, exactly like Glen’s created by_decade object. Let’s say we also have some contextual knowledge, for instance that Disney started to release their movies in the 1930’s. In instances where this is a tremendous amount of data and we wish to perform an operation across elements and retain the knowledge of their index, imap() shines. It sounds niche, but bear with me.
      Glen’s dataframes have a lot information in them, but maybe we want to simplify this down to grabbing names while still retaining pertinent info represented by the index. Many times objects will have their indexes be a categorical divider, in Glen’s situation each index is a decade.
      Let’s build our custom function that we want imap() to apply. For now we will only tell it to grab the “title” column from each dataframe and include its index and then tell imap we want to use this function across each element we pass it and it’s indexes.
# define a function to apply to each element of the list
disneyImap <- function(df, i) {

  df_sub <- df[, c("title","release_year","imdb")]          #grab the title column

  colnames(df_sub) <- paste("Decade_", i, sep = "")   #rename the df to be its index indicator
 
  return(df_sub) #return our df 
}

indexMap <- imap(by_decade$data,disneyImap)

print(indexMap)
## [[1]]
## # A tibble: 2 × 3
##   Decade_1                           ``    ``
##   <chr>                           <dbl> <dbl>
## 1 Academy Award Review of          1937   7.2
## 2 Snow White and the Seven Dwarfs  1937   7.6
## 
## [[2]]
## # A tibble: 14 × 3
##    Decade_2                                  ``    ``
##    <chr>                                  <dbl> <dbl>
##  1 Pinocchio                               1940   7.4
##  2 Fantasia                                1940   7.8
##  3 The Reluctant Dragon                    1941   6.9
##  4 Dumbo                                   1941   7.2
##  5 Bambi                                   1942   7.3
##  6 Saludos Amigos                          1942   6.1
##  7 Victory Through Air Power               1943   6.5
##  8 The Three Caballeros                    1944   6.4
##  9 Make Mine Music                         1946   6.3
## 10 Song of the South                       1946   7.1
## 11 Fun and Fancy Free                      1947   6.6
## 12 Melody Time                             1948   6.4
## 13 So Dear to My Heart                     1948   6.8
## 14 The Adventures of Ichabod and Mr. Toad  1949   7  
## 
## [[3]]
## # A tibble: 28 × 3
##    Decade_3                                      ``    ``
##    <chr>                                      <dbl> <dbl>
##  1 Cinderella                                  1950   6.9
##  2 Treasure Island                             1950   6.9
##  3 Alice in Wonderland                         1951   6.4
##  4 The Story of Robin Hood and His Merrie Men  1952   6.7
##  5 Peter Pan                                   1953   7.3
##  6 The Sword and the Rose                      1953   6.4
##  7 The Living Desert                           1953   7.5
##  8 Rob Roy, the Highland Rogue                 1953   6.3
##  9 The Vanishing Prairie                       1954   7.7
## 10 20,000 Leagues Under the Sea                1954   7.2
## # ℹ 18 more rows
## 
## [[4]]
## # A tibble: 50 × 3
##    Decade_4                          ``    ``
##    <chr>                          <dbl> <dbl>
##  1 Toby Tyler                      1960   7  
##  2 Kidnapped                       1960   7.6
##  3 Pollyanna                       1960   7.4
##  4 Jungle Cat                      1960   7.4
##  5 Ten Who Dared                   1960   5.7
##  6 Swiss Family Robinson           1960   7.2
##  7 One Hundred and One Dalmatians  1961   7.2
##  8 The Parent Trap                 1961   6.5
##  9 Nikki, Wild Dog of the North    1961   6.9
## 10 Greyfriars Bobby                1961   7.3
## # ℹ 40 more rows
## 
## [[5]]
## # A tibble: 46 × 3
##    Decade_5                          ``    ``
##    <chr>                          <dbl> <dbl>
##  1 King of the Grizzlies           1970   5.7
##  2 The Boatniks                    1970   5.5
##  3 The Wild Country                1970   6.4
##  4 The Aristocats                  1970   7.1
##  5 The Barefoot Executive          1971   6  
##  6 Scandalous John                 1971   6.2
##  7 Million Dollar Duck             1971   5.9
##  8 Bedknobs and Broomsticks        1971   7.1
##  9 The Biscuit Eater               1972   5.7
## 10 Now You See Him, Now You Don't  1972   6.3
## # ℹ 36 more rows
## 
## [[6]]
## # A tibble: 27 × 3
##    Decade_6                         ``    ``
##    <chr>                         <dbl> <dbl>
##  1 Midnight Madness               1980   6.5
##  2 The Watcher in the Woods       1980   6.3
##  3 Herbie Goes Bananas            1980   5  
##  4 The Last Flight of Noah's Ark  1980   5.8
##  5 Popeye                         1980   5.3
##  6 The Devil and Max Devlin       1981   5.1
##  7 Amy                            1981   7.8
##  8 Dragonslayer                   1981   6.7
##  9 The Fox and the Hound          1981   7.3
## 10 Condorman                      1981   5.7
## # ℹ 17 more rows
## 
## [[7]]
## # A tibble: 66 × 3
##    Decade_7                                          ``    ``
##    <chr>                                          <dbl> <dbl>
##  1 DuckTales the Movie: Treasure of the Lost Lamp  1990   6.9
##  2 The Rescuers Down Under                         1990   6.9
##  3 White Fang                                      1991   6.7
##  4 Shipwrecked                                     1990   6.7
##  5 Wild Hearts Can't Be Broken                     1991   7.2
##  6 The Rocketeer                                   1991   6.5
##  7 Beauty and the Beast                            1991   8  
##  8 Newsies                                         1992   7  
##  9 Honey, I Blew Up the Kid                        1992   4.9
## 10 The Mighty Ducks                                1992   6.5
## # ℹ 56 more rows
## 
## [[8]]
## # A tibble: 88 × 3
##    Decade_8                     ``    ``
##    <chr>                     <dbl> <dbl>
##  1 The Tigger Movie           2000   6.3
##  2 Dinosaur                   2000   6.5
##  3 The Kid                    2000   8.3
##  4 Remember The Titans        2000   7.8
##  5 102 Dalmatians             2000   4.9
##  6 The Emperor's New Groove   2000   7.3
##  7 Recess: School's Out       2001   6.6
##  8 Atlantis: The Lost Empire  2001   6.9
##  9 The Princess Diaries       2001   6.3
## 10 Max Keeble's Big Move      2001   5.4
## # ℹ 78 more rows
## 
## [[9]]
## # A tibble: 79 × 3
##    Decade_9                                    ``    ``
##    <chr>                                    <dbl> <dbl>
##  1 Alice in Wonderland                       2010   6.4
##  2 Prince of Persia: The Sands of Time       2010   6.6
##  3 Toy Story 3                               2010   8.3
##  4 The Sorcerer's Apprentice                 2010   6.1
##  5 Secretariat                               2010   7.2
##  6 Do Dooni Chaar                            2010   7.6
##  7 Tangled                                   2010   7.7
##  8 Tron: Legacy                              2010   6.8
##  9 Lilly the Witch: The Journey to Mandolan  2011   4.8
## 10 Mars Needs Moms                           2011   5.4
## # ℹ 69 more rows
## 
## [[10]]
## # A tibble: 13 × 3
##    Decade_10                            ``    ``
##    <chr>                             <dbl> <dbl>
##  1 Timmy Failure: Mistakes Were Made  2020   6.1
##  2 Onward                             2020   7.4
##  3 Stargirl                           2020   7.3
##  4 Elephant                           2020   7.2
##  5 Artemis Fowl                       2020   4.1
##  6 Hamilton                           2020   8.7
##  7 Black Is King                      2020   5.4
##  8 Magic Camp                         2020   6.3
##  9 The One and Only Ivan              2020   6.7
## 10 Mulan                              2020   7.6
## 11 Clouds                             2020   6.6
## 12 Soul                               2020   7  
## 13 The Beatles: Get Back              2021   8
      After viewing this result, imagine if we had a dataset for books documented since the first written story, in a historical context such as researching evolution of writing across time. That dataset would have a lot of decades/nested data frames. You could certianly handle Disney’s movies by hand, but purrr’s imap allows you to iterate across the elements and retain its index (decade), so that if we only wanted specific pieces inside each element, we can apply our custom function and then keep its index for contextual purposes.

map2(): processes across pairs of elements

      We will use map2 to compare films by decade. Map2 performs analysis across lists or vectors with paired elements, so objects passed to it need to have the same dimensions. This would be great for when you are running a Matched Pairs Experiment and data is heavily nested due to pulling from an API with a heavy JSON file. Let’s see if we can perform some rating comparisons on the 40s titles and the first 14 titles in the 90s. Let’s use map() to set ourselves up by reducing the decade dataframes to include the IMDB score so we can compare between decade dataframes.
subsetFun <- function(df) {       # pull the imdb column from the df passed
  df_sub <- df[, c("imdb")]
  return(df_sub)
}

disneyDecadeComparison <- map(by_decade$data, subsetFun)   #apply our function to all the df's

dec90<-disneyDecadeComparison[[7]][1:14,]           #grab the first 14 title scores from the 90s

titleDiff <- map2_dfc(disneyDecadeComparison[[2]],dec90, `-`) #subtract the corresponding title values between the dataframes
print(titleDiff) #show our new df
## # A tibble: 14 × 1
##      imdb
##     <dbl>
##  1  0.5  
##  2  0.900
##  3  0.200
##  4  0.5  
##  5  0.100
##  6 -0.400
##  7 -1.5  
##  8 -0.600
##  9  1.4  
## 10  0.600
## 11 -1.4  
## 12 -1.3  
## 13 -0.100
## 14  0.400
print(sum(titleDiff)) #show our difference
## [1] -0.7
      It looks like the first set of 90s films collectively have a higher rating by -0.7.

pmap(): same as map2, but allows for processing across more than two objects

        What if someone had the belief that Disney’s first movies in any decade received less scrutiny, and that as time progessed within 10 year blocks, the ratings grew more harsh. Under this strange theory, let’s use purrr’s pmap to create averages across the first movies across decades in comparison with each other. We’ll drop the first decade’s movies since there were only 2 made in the 30s and take the first 13 movies since there’s only been 13 in 2020. We need our dimensions to be the same across our elements when we passit to pmap() or the function will break. To accomplish this we will need to use map!
shortenFun <- function(df) {       # shorten all the columns
  df_sub <- df[1:13,]
  return(df_sub)
}

first13 <- map(disneyDecadeComparison[2:10], shortenFun) %>% 
  bind_cols()
## New names:
## • `imdb` -> `imdb...1`
## • `imdb` -> `imdb...2`
## • `imdb` -> `imdb...3`
## • `imdb` -> `imdb...4`
## • `imdb` -> `imdb...5`
## • `imdb` -> `imdb...6`
## • `imdb` -> `imdb...7`
## • `imdb` -> `imdb...8`
## • `imdb` -> `imdb...9`
paged_table(first13)
      Above we can see how map helped us pull data out and re-bind them into the form we need. Now we can work on using pmap to generate our averages.
avg <- pmap_dbl(first13, ~mean(..3, trim = 0)) # we set the value for the mean function to 0 here because it couldnt tell how many observations to include in its averaging due to the complicated setup. Setting it to 0 tells the mean function to include all observations.

print(avg)
##  [1] 7.0 7.6 7.4 7.4 5.7 7.2 7.2 6.5 6.9 7.3 6.3 5.4 5.8
      We can now use this vector of averages to throw it back on to our other data for a clean look.
first13Avg <- first13 %>%
  mutate(mean = avg) %>%
  mutate(seqMovie = rownames(first13)) %>%
  select(seqMovie, mean,everything())

colnames(first13Avg) <- c('seqMovie','mean','40s','50s','60s','70s','80s','90s','2000s','2010s','2020s')


paged_table(first13Avg)
      We can see that the 5th movie of every decade on average had the lowest ratings. I’m sure the next burning question in all of our minds is: Is there a evidence to suggest that the 5th movie in any decade produced by Disney are worse than the others or is this just variance? Find out by taking DATA606 at CUNY to perform a hypothesis test and find out!

Filter Commands & List operations

      Purrr has a wonderful section dedicated to filtering lists and manipulating lists. Let’s try using some of the critical ones here.

keep(): selects the elements of a list that meet a criteria

      Let’s say we are working with our by_decade$data list again. This list contains dataframes organized by their release date, that is to say, each dataframe is representative of a decade in Disney’s time of production. We’ve been tasked with filtering this so we only work with the dataframes that represent movies from the 80s forward. Let’s see if we can filter our dataframes so our release_year column states 1980 or later.
by_decade$data
## <list_of<
##   tbl_df<
##     title                       : character
##     production_company          : character
##     release_date                : character
##     running_time                : character
##     country                     : character
##     language                    : character
##     running_time_int            : integer
##     budget_float_in_millions    : double
##     box_office_float_in_millions: double
##     release_date_datetime       : date
##     imdb                        : double
##     metascore                   : integer
##     rotten_tomatoes             : double
##     directed_by                 : character
##     produced_by                 : character
##     written_by                  : character
##     based_on                    : character
##     starring                    : character
##     music_by                    : character
##     distributed_by              : character
##     budget                      : character
##     box_office                  : character
##     story_by                    : character
##     narrated_by                 : character
##     cinematography              : character
##     edited_by                   : character
##     screenplay_by               : character
##     production_companies        : character
##     adaptation_by               : character
##     traditional                 : character
##     simplified                  : character
##     release_year                : double
##   >
## >[10]>
## [[1]]
## # A tibble: 2 × 32
##   title            production_company release_date running_time country language
##   <chr>            <chr>              <chr>        <chr>        <chr>   <chr>   
## 1 Academy Award R… Walt Disney Produ… ['May 19, 1… 41 minutes … United… English 
## 2 Snow White and … Walt Disney Produ… ['December … 83 minutes   United… English 
## # ℹ 26 more variables: running_time_int <int>, budget_float_in_millions <dbl>,
## #   box_office_float_in_millions <dbl>, release_date_datetime <date>,
## #   imdb <dbl>, metascore <int>, rotten_tomatoes <dbl>, directed_by <chr>,
## #   produced_by <chr>, written_by <chr>, based_on <chr>, starring <chr>,
## #   music_by <chr>, distributed_by <chr>, budget <chr>, box_office <chr>,
## #   story_by <chr>, narrated_by <chr>, cinematography <chr>, edited_by <chr>,
## #   screenplay_by <chr>, production_companies <chr>, adaptation_by <chr>, …
## 
## [[2]]
## # A tibble: 14 × 32
##    title           production_company release_date running_time country language
##    <chr>           <chr>              <chr>        <chr>        <chr>   <chr>   
##  1 Pinocchio       Walt Disney Produ… ['February … 88 minutes   United… English 
##  2 Fantasia        Walt Disney Produ… ['November … 126 minutes  United… English 
##  3 The Reluctant … Walt Disney Produ… ['June 20, … 74 minutes   United… English 
##  4 Dumbo           Walt Disney Produ… ['October 2… 64 minutes   United… English 
##  5 Bambi           Walt Disney Produ… ['August 9,… 70 minutes   United… English 
##  6 Saludos Amigos  Walt Disney Produ… ['August 24… 42 minutes   United… ['Engli…
##  7 Victory Throug… Walt Disney Produ… ['July 17, … 65 min.      United… English 
##  8 The Three Caba… Walt Disney Produ… ['December … 71 minutes   United… ['Engli…
##  9 Make Mine Music Walt Disney Produ… ['April 20,… 75 minutes   United… English 
## 10 Song of the So… Walt Disney Produ… ['November … 94 minutes   United… English 
## 11 Fun and Fancy … Walt Disney Produ… ['September… 73 minutes   United… English 
## 12 Melody Time     Walt Disney Produ… May 27, 1948 75 minutes   United… English 
## 13 So Dear to My … Walt Disney Produ… ['November … 82 minutes   United… English 
## 14 The Adventures… Walt Disney Produ… ['October 5… 68 minutes   United… English 
## # ℹ 26 more variables: running_time_int <int>, budget_float_in_millions <dbl>,
## #   box_office_float_in_millions <dbl>, release_date_datetime <date>,
## #   imdb <dbl>, metascore <int>, rotten_tomatoes <dbl>, directed_by <chr>,
## #   produced_by <chr>, written_by <chr>, based_on <chr>, starring <chr>,
## #   music_by <chr>, distributed_by <chr>, budget <chr>, box_office <chr>,
## #   story_by <chr>, narrated_by <chr>, cinematography <chr>, edited_by <chr>,
## #   screenplay_by <chr>, production_companies <chr>, adaptation_by <chr>, …
## 
## [[3]]
## # A tibble: 28 × 32
##    title           production_company release_date running_time country language
##    <chr>           <chr>              <chr>        <chr>        <chr>   <chr>   
##  1 Cinderella      Walt Disney Produ… ['February … 74 minutes   United… English 
##  2 Treasure Island Walt Disney Produ… ['June 22, … 96 minutes   ['Unit… English 
##  3 Alice in Wonde… Walt Disney Produ… ['July 26, … 75 minutes   United… English 
##  4 The Story of R… ['Walt Disney Pro… ['March 13,… 84 minutes   ['Unit… English 
##  5 Peter Pan       Walt Disney Produ… ['February … 77 minutes   United… English 
##  6 The Sword and … Walt Disney Produ… ['August 8,… 92 minutes   ['Unit… English 
##  7 The Living Des… Walt Disney Produ… November 10… 69 minutes   United… English 
##  8 Rob Roy, the H… Walt Disney Produ… ['26 Octobe… 81 minutes   ['Unit… English 
##  9 The Vanishing … Walt Disney Produ… ['August 17… ['60 minute… United… English 
## 10 20,000 Leagues… Walt Disney Produ… ['December … 127 minutes  United… English 
## # ℹ 18 more rows
## # ℹ 26 more variables: running_time_int <int>, budget_float_in_millions <dbl>,
## #   box_office_float_in_millions <dbl>, release_date_datetime <date>,
## #   imdb <dbl>, metascore <int>, rotten_tomatoes <dbl>, directed_by <chr>,
## #   produced_by <chr>, written_by <chr>, based_on <chr>, starring <chr>,
## #   music_by <chr>, distributed_by <chr>, budget <chr>, box_office <chr>,
## #   story_by <chr>, narrated_by <chr>, cinematography <chr>, edited_by <chr>, …
## 
## [[4]]
## # A tibble: 50 × 32
##    title           production_company release_date running_time country language
##    <chr>           <chr>              <chr>        <chr>        <chr>   <chr>   
##  1 Toby Tyler      Walt Disney Produ… January 21,… 95 minutes   United… English 
##  2 Kidnapped       Walt Disney Produ… ['February … 97 minutes   United… English…
##  3 Pollyanna       Walt Disney Produ… May 19, 1960 134 minutes  United… English 
##  4 Jungle Cat      Walt Disney Produ… ['August 10… 69 minutes   United… English 
##  5 Ten Who Dared   Walt Disney Produ… ['November … 92 minutes   United… English 
##  6 Swiss Family R… Walt Disney Produ… ['December … 126 minutes  United… English 
##  7 One Hundred an… Walt Disney Produ… ['January 2… 79 minutes   United… English 
##  8 The Parent Trap Walt Disney Produ… ['June 21, … 128 minutes  United… English 
##  9 Nikki, Wild Do… Walt Disney Produ… ['July 12, … 74 minutes   United… English 
## 10 Greyfriars Bob… Walt Disney Produ… ['July 17, … 91 minutes   United… English 
## # ℹ 40 more rows
## # ℹ 26 more variables: running_time_int <int>, budget_float_in_millions <dbl>,
## #   box_office_float_in_millions <dbl>, release_date_datetime <date>,
## #   imdb <dbl>, metascore <int>, rotten_tomatoes <dbl>, directed_by <chr>,
## #   produced_by <chr>, written_by <chr>, based_on <chr>, starring <chr>,
## #   music_by <chr>, distributed_by <chr>, budget <chr>, box_office <chr>,
## #   story_by <chr>, narrated_by <chr>, cinematography <chr>, edited_by <chr>, …
## 
## [[5]]
## # A tibble: 46 × 32
##    title           production_company release_date running_time country language
##    <chr>           <chr>              <chr>        <chr>        <chr>   <chr>   
##  1 King of the Gr… Walt Disney Produ… ['February … 93 minutes   ['Unit… English 
##  2 The Boatniks    Walt Disney Produ… July 1, 1970 100 minutes  United… English 
##  3 The Wild Count… Walt Disney Produ… ['December … 100 minutes  United… English 
##  4 The Aristocats  Walt Disney Produ… ['December … 79 minutes   United… English 
##  5 The Barefoot E… Walt Disney Produ… March 17, 1… 96 minutes   United… English 
##  6 Scandalous John Walt Disney Produ… June 22, 19… 113 minutes  United… English 
##  7 Million Dollar… Walt Disney Produ… ['June 30, … 89 minutes   United… English 
##  8 Bedknobs and B… Walt Disney Produ… ['October 7… ['118 minut… United… English 
##  9 The Biscuit Ea… Walt Disney Produ… ['March 22,… 92 minutes   United… English 
## 10 Now You See Hi… Walt Disney Produ… July 12, 19… 88 minutes   United… English 
## # ℹ 36 more rows
## # ℹ 26 more variables: running_time_int <int>, budget_float_in_millions <dbl>,
## #   box_office_float_in_millions <dbl>, release_date_datetime <date>,
## #   imdb <dbl>, metascore <int>, rotten_tomatoes <dbl>, directed_by <chr>,
## #   produced_by <chr>, written_by <chr>, based_on <chr>, starring <chr>,
## #   music_by <chr>, distributed_by <chr>, budget <chr>, box_office <chr>,
## #   story_by <chr>, narrated_by <chr>, cinematography <chr>, edited_by <chr>, …
## 
## [[6]]
## # A tibble: 27 × 32
##    title           production_company release_date running_time country language
##    <chr>           <chr>              <chr>        <chr>        <chr>   <chr>   
##  1 Midnight Madne… Walt Disney Produ… ['February … 112 minutes  United… English 
##  2 The Watcher in… Walt Disney Produ… ['April 17,… 84 minutes   United… English 
##  3 Herbie Goes Ba… Walt Disney Produ… ['June 27, … 98 minutes   United… English 
##  4 The Last Fligh… Walt Disney Produ… ['July 9, 1… 97 minutes   United… English 
##  5 Popeye          ['Paramount Pictu… ['December … 114 minutes  United… English 
##  6 The Devil and … Walt Disney Produ… February 11… 96 minutes   United… English 
##  7 Amy             Walt Disney Produ… March 20, 1… 100 minutes  United… English 
##  8 Dragonslayer    ['Paramount Pictu… ['June 26, … 109 minutes  United… English 
##  9 The Fox and th… Walt Disney Produ… ['July 10, … 83 minutes   United… English 
## 10 Condorman       Walt Disney Produ… ['August 7,… 90 minutes   United… English 
## # ℹ 17 more rows
## # ℹ 26 more variables: running_time_int <int>, budget_float_in_millions <dbl>,
## #   box_office_float_in_millions <dbl>, release_date_datetime <date>,
## #   imdb <dbl>, metascore <int>, rotten_tomatoes <dbl>, directed_by <chr>,
## #   produced_by <chr>, written_by <chr>, based_on <chr>, starring <chr>,
## #   music_by <chr>, distributed_by <chr>, budget <chr>, box_office <chr>,
## #   story_by <chr>, narrated_by <chr>, cinematography <chr>, edited_by <chr>, …
## 
## [[7]]
## # A tibble: 66 × 32
##    title           production_company release_date running_time country language
##    <chr>           <chr>              <chr>        <chr>        <chr>   <chr>   
##  1 DuckTales the … <NA>               ['August 3,… 69 minutes   United… English 
##  2 The Rescuers D… ['Walt Disney Pic… ['November … 77 minutes   United… English 
##  3 White Fang      ['Walt Disney Pic… ['January 1… 107 minutes  United… English 
##  4 Shipwrecked     ['Walt Disney Pic… ['3 October… 93 minutes   ['Norw… ['Norwe…
##  5 Wild Hearts Ca… Walt Disney Pictu… ['May 24, 1… 88 minutes   United… English 
##  6 The Rocketeer   <NA>               ['June 21, … 108 minutes  United… English 
##  7 Beauty and the… <NA>               ['September… 84 minutes   United… English 
##  8 Newsies         Walt Disney Pictu… ['April 10,… 121 minutes  United… English 
##  9 Honey, I Blew … ['Walt Disney Pic… ['July 17, … 89 minutes   United… English 
## 10 The Mighty Duc… ['Walt Disney Pic… ['October 2… 104 minutes  United… English 
## # ℹ 56 more rows
## # ℹ 26 more variables: running_time_int <int>, budget_float_in_millions <dbl>,
## #   box_office_float_in_millions <dbl>, release_date_datetime <date>,
## #   imdb <dbl>, metascore <int>, rotten_tomatoes <dbl>, directed_by <chr>,
## #   produced_by <chr>, written_by <chr>, based_on <chr>, starring <chr>,
## #   music_by <chr>, distributed_by <chr>, budget <chr>, box_office <chr>,
## #   story_by <chr>, narrated_by <chr>, cinematography <chr>, edited_by <chr>, …
## 
## [[8]]
## # A tibble: 88 × 32
##    title           production_company release_date running_time country language
##    <chr>           <chr>              <chr>        <chr>        <chr>   <chr>   
##  1 The Tigger Mov… ['Walt Disney Tel… ['February … 77 minutes   United… English 
##  2 Dinosaur        ['Walt Disney Pic… ['May 19, 2… 82 minutes   United… English 
##  3 The Kid         Walt Disney Pictu… ['July 7, 2… 104 minutes  United… English 
##  4 Remember The T… ['Walt Disney Pic… ['September… 113 minutes  United… English 
##  5 102 Dalmatians  ['Walt Disney Pic… ['November … 100 minutes  United… English 
##  6 The Emperor's … ['Walt Disney Pic… ['December … 78 minutes   United… English 
##  7 Recess: School… ['Walt Disney Pic… ['February … 83 minutes   United… English 
##  8 Atlantis: The … ['Walt Disney Pic… ['June 3, 2… 96 minutes   United… English 
##  9 The Princess D… ['Walt Disney Pic… ['August 3,… 115 minutes  United… English 
## 10 Max Keeble's B… ['Walt Disney Pic… ['October 5… 86 minutes   United… English 
## # ℹ 78 more rows
## # ℹ 26 more variables: running_time_int <int>, budget_float_in_millions <dbl>,
## #   box_office_float_in_millions <dbl>, release_date_datetime <date>,
## #   imdb <dbl>, metascore <int>, rotten_tomatoes <dbl>, directed_by <chr>,
## #   produced_by <chr>, written_by <chr>, based_on <chr>, starring <chr>,
## #   music_by <chr>, distributed_by <chr>, budget <chr>, box_office <chr>,
## #   story_by <chr>, narrated_by <chr>, cinematography <chr>, edited_by <chr>, …
## 
## [[9]]
## # A tibble: 79 × 32
##    title           production_company release_date running_time country language
##    <chr>           <chr>              <chr>        <chr>        <chr>   <chr>   
##  1 Alice in Wonde… ['Walt Disney Pic… ['February … 108 minutes  United… English 
##  2 Prince of Pers… <NA>               ['May 9, 20… 116 minutes  United… English 
##  3 Toy Story 3     ['Walt Disney Pic… ['June 12, … 103 minutes  United… English 
##  4 The Sorcerer's… ['Walt Disney Pic… ['July 8, 2… 109 minutes  United… English 
##  5 Secretariat     ['Walt Disney Pic… ['September… 123 minutes  United… English 
##  6 Do Dooni Chaar  ['Walt Disney Pic… ['8 October… 108 minutes  India   Hindi   
##  7 Tangled         ['Walt Disney Pic… ['November … 100 minutes  United… English 
##  8 Tron: Legacy    <NA>               ['November … 125 minutes  United… English 
##  9 Lilly the Witc… Walt Disney Pictu… ['17 Februa… 90 minutes   Germany German  
## 10 Mars Needs Moms ['Walt Disney Pic… ['March 11,… 88 minutes   United… English 
## # ℹ 69 more rows
## # ℹ 26 more variables: running_time_int <int>, budget_float_in_millions <dbl>,
## #   box_office_float_in_millions <dbl>, release_date_datetime <date>,
## #   imdb <dbl>, metascore <int>, rotten_tomatoes <dbl>, directed_by <chr>,
## #   produced_by <chr>, written_by <chr>, based_on <chr>, starring <chr>,
## #   music_by <chr>, distributed_by <chr>, budget <chr>, box_office <chr>,
## #   story_by <chr>, narrated_by <chr>, cinematography <chr>, edited_by <chr>, …
## 
## [[10]]
## # A tibble: 13 × 32
##    title           production_company release_date running_time country language
##    <chr>           <chr>              <chr>        <chr>        <chr>   <chr>   
##  1 Timmy Failure:… ['Walt Disney Pic… ['January 2… 99 minutes   United… English 
##  2 Onward          ['Walt Disney Pic… ['February … 102 minutes  United… <NA>    
##  3 Stargirl        ['Walt Disney Pic… ['March 13,… 107 minutes  United… English 
##  4 Elephant        Disneynature       ['April 3, … 89 minutes   United… English 
##  5 Artemis Fowl    ['Walt Disney Pic… ['June 12, … 95 minutes   United… English 
##  6 Hamilton        ['Walt Disney Pic… ['July 3, 2… 160 minutes  United… English 
##  7 Black Is King   ['Parkwood Entert… ['July 31, … 85 minutes   United… English 
##  8 Magic Camp      ['Walt Disney Pic… ['August 14… 100 minutes  United… English 
##  9 The One and On… ['Walt Disney Pic… ['August 21… 95 minutes   United… English 
## 10 Mulan           ['Walt Disney Pic… ['March 9, … 115 minutes  United… English 
## 11 Clouds          <NA>               ['October 1… <NA>         United… English 
## 12 Soul            ['Walt Disney Pic… ['October 1… <NA>         United… English 
## 13 The Beatles: G… <NA>               ['27 August… <NA>         ['Unit… English 
## # ℹ 26 more variables: running_time_int <int>, budget_float_in_millions <dbl>,
## #   box_office_float_in_millions <dbl>, release_date_datetime <date>,
## #   imdb <dbl>, metascore <int>, rotten_tomatoes <dbl>, directed_by <chr>,
## #   produced_by <chr>, written_by <chr>, based_on <chr>, starring <chr>,
## #   music_by <chr>, distributed_by <chr>, budget <chr>, box_office <chr>,
## #   story_by <chr>, narrated_by <chr>, cinematography <chr>, edited_by <chr>,
## #   screenplay_by <chr>, production_companies <chr>, adaptation_by <chr>, …
laterThan80 <- by_decade$data %>%
  keep(~min(.x[["release_year"]]) >= 1980)

laterThan80
## <list_of<
##   tbl_df<
##     title                       : character
##     production_company          : character
##     release_date                : character
##     running_time                : character
##     country                     : character
##     language                    : character
##     running_time_int            : integer
##     budget_float_in_millions    : double
##     box_office_float_in_millions: double
##     release_date_datetime       : date
##     imdb                        : double
##     metascore                   : integer
##     rotten_tomatoes             : double
##     directed_by                 : character
##     produced_by                 : character
##     written_by                  : character
##     based_on                    : character
##     starring                    : character
##     music_by                    : character
##     distributed_by              : character
##     budget                      : character
##     box_office                  : character
##     story_by                    : character
##     narrated_by                 : character
##     cinematography              : character
##     edited_by                   : character
##     screenplay_by               : character
##     production_companies        : character
##     adaptation_by               : character
##     traditional                 : character
##     simplified                  : character
##     release_year                : double
##   >
## >[5]>
## [[1]]
## # A tibble: 27 × 32
##    title           production_company release_date running_time country language
##    <chr>           <chr>              <chr>        <chr>        <chr>   <chr>   
##  1 Midnight Madne… Walt Disney Produ… ['February … 112 minutes  United… English 
##  2 The Watcher in… Walt Disney Produ… ['April 17,… 84 minutes   United… English 
##  3 Herbie Goes Ba… Walt Disney Produ… ['June 27, … 98 minutes   United… English 
##  4 The Last Fligh… Walt Disney Produ… ['July 9, 1… 97 minutes   United… English 
##  5 Popeye          ['Paramount Pictu… ['December … 114 minutes  United… English 
##  6 The Devil and … Walt Disney Produ… February 11… 96 minutes   United… English 
##  7 Amy             Walt Disney Produ… March 20, 1… 100 minutes  United… English 
##  8 Dragonslayer    ['Paramount Pictu… ['June 26, … 109 minutes  United… English 
##  9 The Fox and th… Walt Disney Produ… ['July 10, … 83 minutes   United… English 
## 10 Condorman       Walt Disney Produ… ['August 7,… 90 minutes   United… English 
## # ℹ 17 more rows
## # ℹ 26 more variables: running_time_int <int>, budget_float_in_millions <dbl>,
## #   box_office_float_in_millions <dbl>, release_date_datetime <date>,
## #   imdb <dbl>, metascore <int>, rotten_tomatoes <dbl>, directed_by <chr>,
## #   produced_by <chr>, written_by <chr>, based_on <chr>, starring <chr>,
## #   music_by <chr>, distributed_by <chr>, budget <chr>, box_office <chr>,
## #   story_by <chr>, narrated_by <chr>, cinematography <chr>, edited_by <chr>, …
## 
## [[2]]
## # A tibble: 66 × 32
##    title           production_company release_date running_time country language
##    <chr>           <chr>              <chr>        <chr>        <chr>   <chr>   
##  1 DuckTales the … <NA>               ['August 3,… 69 minutes   United… English 
##  2 The Rescuers D… ['Walt Disney Pic… ['November … 77 minutes   United… English 
##  3 White Fang      ['Walt Disney Pic… ['January 1… 107 minutes  United… English 
##  4 Shipwrecked     ['Walt Disney Pic… ['3 October… 93 minutes   ['Norw… ['Norwe…
##  5 Wild Hearts Ca… Walt Disney Pictu… ['May 24, 1… 88 minutes   United… English 
##  6 The Rocketeer   <NA>               ['June 21, … 108 minutes  United… English 
##  7 Beauty and the… <NA>               ['September… 84 minutes   United… English 
##  8 Newsies         Walt Disney Pictu… ['April 10,… 121 minutes  United… English 
##  9 Honey, I Blew … ['Walt Disney Pic… ['July 17, … 89 minutes   United… English 
## 10 The Mighty Duc… ['Walt Disney Pic… ['October 2… 104 minutes  United… English 
## # ℹ 56 more rows
## # ℹ 26 more variables: running_time_int <int>, budget_float_in_millions <dbl>,
## #   box_office_float_in_millions <dbl>, release_date_datetime <date>,
## #   imdb <dbl>, metascore <int>, rotten_tomatoes <dbl>, directed_by <chr>,
## #   produced_by <chr>, written_by <chr>, based_on <chr>, starring <chr>,
## #   music_by <chr>, distributed_by <chr>, budget <chr>, box_office <chr>,
## #   story_by <chr>, narrated_by <chr>, cinematography <chr>, edited_by <chr>, …
## 
## [[3]]
## # A tibble: 88 × 32
##    title           production_company release_date running_time country language
##    <chr>           <chr>              <chr>        <chr>        <chr>   <chr>   
##  1 The Tigger Mov… ['Walt Disney Tel… ['February … 77 minutes   United… English 
##  2 Dinosaur        ['Walt Disney Pic… ['May 19, 2… 82 minutes   United… English 
##  3 The Kid         Walt Disney Pictu… ['July 7, 2… 104 minutes  United… English 
##  4 Remember The T… ['Walt Disney Pic… ['September… 113 minutes  United… English 
##  5 102 Dalmatians  ['Walt Disney Pic… ['November … 100 minutes  United… English 
##  6 The Emperor's … ['Walt Disney Pic… ['December … 78 minutes   United… English 
##  7 Recess: School… ['Walt Disney Pic… ['February … 83 minutes   United… English 
##  8 Atlantis: The … ['Walt Disney Pic… ['June 3, 2… 96 minutes   United… English 
##  9 The Princess D… ['Walt Disney Pic… ['August 3,… 115 minutes  United… English 
## 10 Max Keeble's B… ['Walt Disney Pic… ['October 5… 86 minutes   United… English 
## # ℹ 78 more rows
## # ℹ 26 more variables: running_time_int <int>, budget_float_in_millions <dbl>,
## #   box_office_float_in_millions <dbl>, release_date_datetime <date>,
## #   imdb <dbl>, metascore <int>, rotten_tomatoes <dbl>, directed_by <chr>,
## #   produced_by <chr>, written_by <chr>, based_on <chr>, starring <chr>,
## #   music_by <chr>, distributed_by <chr>, budget <chr>, box_office <chr>,
## #   story_by <chr>, narrated_by <chr>, cinematography <chr>, edited_by <chr>, …
## 
## [[4]]
## # A tibble: 79 × 32
##    title           production_company release_date running_time country language
##    <chr>           <chr>              <chr>        <chr>        <chr>   <chr>   
##  1 Alice in Wonde… ['Walt Disney Pic… ['February … 108 minutes  United… English 
##  2 Prince of Pers… <NA>               ['May 9, 20… 116 minutes  United… English 
##  3 Toy Story 3     ['Walt Disney Pic… ['June 12, … 103 minutes  United… English 
##  4 The Sorcerer's… ['Walt Disney Pic… ['July 8, 2… 109 minutes  United… English 
##  5 Secretariat     ['Walt Disney Pic… ['September… 123 minutes  United… English 
##  6 Do Dooni Chaar  ['Walt Disney Pic… ['8 October… 108 minutes  India   Hindi   
##  7 Tangled         ['Walt Disney Pic… ['November … 100 minutes  United… English 
##  8 Tron: Legacy    <NA>               ['November … 125 minutes  United… English 
##  9 Lilly the Witc… Walt Disney Pictu… ['17 Februa… 90 minutes   Germany German  
## 10 Mars Needs Moms ['Walt Disney Pic… ['March 11,… 88 minutes   United… English 
## # ℹ 69 more rows
## # ℹ 26 more variables: running_time_int <int>, budget_float_in_millions <dbl>,
## #   box_office_float_in_millions <dbl>, release_date_datetime <date>,
## #   imdb <dbl>, metascore <int>, rotten_tomatoes <dbl>, directed_by <chr>,
## #   produced_by <chr>, written_by <chr>, based_on <chr>, starring <chr>,
## #   music_by <chr>, distributed_by <chr>, budget <chr>, box_office <chr>,
## #   story_by <chr>, narrated_by <chr>, cinematography <chr>, edited_by <chr>, …
## 
## [[5]]
## # A tibble: 13 × 32
##    title           production_company release_date running_time country language
##    <chr>           <chr>              <chr>        <chr>        <chr>   <chr>   
##  1 Timmy Failure:… ['Walt Disney Pic… ['January 2… 99 minutes   United… English 
##  2 Onward          ['Walt Disney Pic… ['February … 102 minutes  United… <NA>    
##  3 Stargirl        ['Walt Disney Pic… ['March 13,… 107 minutes  United… English 
##  4 Elephant        Disneynature       ['April 3, … 89 minutes   United… English 
##  5 Artemis Fowl    ['Walt Disney Pic… ['June 12, … 95 minutes   United… English 
##  6 Hamilton        ['Walt Disney Pic… ['July 3, 2… 160 minutes  United… English 
##  7 Black Is King   ['Parkwood Entert… ['July 31, … 85 minutes   United… English 
##  8 Magic Camp      ['Walt Disney Pic… ['August 14… 100 minutes  United… English 
##  9 The One and On… ['Walt Disney Pic… ['August 21… 95 minutes   United… English 
## 10 Mulan           ['Walt Disney Pic… ['March 9, … 115 minutes  United… English 
## 11 Clouds          <NA>               ['October 1… <NA>         United… English 
## 12 Soul            ['Walt Disney Pic… ['October 1… <NA>         United… English 
## 13 The Beatles: G… <NA>               ['27 August… <NA>         ['Unit… English 
## # ℹ 26 more variables: running_time_int <int>, budget_float_in_millions <dbl>,
## #   box_office_float_in_millions <dbl>, release_date_datetime <date>,
## #   imdb <dbl>, metascore <int>, rotten_tomatoes <dbl>, directed_by <chr>,
## #   produced_by <chr>, written_by <chr>, based_on <chr>, starring <chr>,
## #   music_by <chr>, distributed_by <chr>, budget <chr>, box_office <chr>,
## #   story_by <chr>, narrated_by <chr>, cinematography <chr>, edited_by <chr>,
## #   screenplay_by <chr>, production_companies <chr>, adaptation_by <chr>, …

compact(): drop empty elements

      Let’s say our intern data analyst accidentally pulled the information about the Disney movies with some NA’s. Earlier Glen hanlded that by filtering by NA’s before grouping our movies into the list we are currently using, by_decade. In this hypothetical, let’s assume we didn’t create the by_decade list and realized there are some NA’s in the 2000s dataframe that we need to discuss with our study director on how he wants to handle.
laterThan80[[3]] <- NULL
laterThan80[[3]]
## NULL
      For now he told us to ignore the 2000s and ask the intern about getting the original data. Just as dplyr is to dataframes, purrr is to lists. Let’s prep our data and leave out the decade of 2000s by using compact() on our list to only include non-null values in our elements.
laterThan80 %>%
  compact(~.x)
## <list_of<
##   tbl_df<
##     title                       : character
##     production_company          : character
##     release_date                : character
##     running_time                : character
##     country                     : character
##     language                    : character
##     running_time_int            : integer
##     budget_float_in_millions    : double
##     box_office_float_in_millions: double
##     release_date_datetime       : date
##     imdb                        : double
##     metascore                   : integer
##     rotten_tomatoes             : double
##     directed_by                 : character
##     produced_by                 : character
##     written_by                  : character
##     based_on                    : character
##     starring                    : character
##     music_by                    : character
##     distributed_by              : character
##     budget                      : character
##     box_office                  : character
##     story_by                    : character
##     narrated_by                 : character
##     cinematography              : character
##     edited_by                   : character
##     screenplay_by               : character
##     production_companies        : character
##     adaptation_by               : character
##     traditional                 : character
##     simplified                  : character
##     release_year                : double
##   >
## >[4]>
## [[1]]
## # A tibble: 27 × 32
##    title           production_company release_date running_time country language
##    <chr>           <chr>              <chr>        <chr>        <chr>   <chr>   
##  1 Midnight Madne… Walt Disney Produ… ['February … 112 minutes  United… English 
##  2 The Watcher in… Walt Disney Produ… ['April 17,… 84 minutes   United… English 
##  3 Herbie Goes Ba… Walt Disney Produ… ['June 27, … 98 minutes   United… English 
##  4 The Last Fligh… Walt Disney Produ… ['July 9, 1… 97 minutes   United… English 
##  5 Popeye          ['Paramount Pictu… ['December … 114 minutes  United… English 
##  6 The Devil and … Walt Disney Produ… February 11… 96 minutes   United… English 
##  7 Amy             Walt Disney Produ… March 20, 1… 100 minutes  United… English 
##  8 Dragonslayer    ['Paramount Pictu… ['June 26, … 109 minutes  United… English 
##  9 The Fox and th… Walt Disney Produ… ['July 10, … 83 minutes   United… English 
## 10 Condorman       Walt Disney Produ… ['August 7,… 90 minutes   United… English 
## # ℹ 17 more rows
## # ℹ 26 more variables: running_time_int <int>, budget_float_in_millions <dbl>,
## #   box_office_float_in_millions <dbl>, release_date_datetime <date>,
## #   imdb <dbl>, metascore <int>, rotten_tomatoes <dbl>, directed_by <chr>,
## #   produced_by <chr>, written_by <chr>, based_on <chr>, starring <chr>,
## #   music_by <chr>, distributed_by <chr>, budget <chr>, box_office <chr>,
## #   story_by <chr>, narrated_by <chr>, cinematography <chr>, edited_by <chr>, …
## 
## [[2]]
## # A tibble: 66 × 32
##    title           production_company release_date running_time country language
##    <chr>           <chr>              <chr>        <chr>        <chr>   <chr>   
##  1 DuckTales the … <NA>               ['August 3,… 69 minutes   United… English 
##  2 The Rescuers D… ['Walt Disney Pic… ['November … 77 minutes   United… English 
##  3 White Fang      ['Walt Disney Pic… ['January 1… 107 minutes  United… English 
##  4 Shipwrecked     ['Walt Disney Pic… ['3 October… 93 minutes   ['Norw… ['Norwe…
##  5 Wild Hearts Ca… Walt Disney Pictu… ['May 24, 1… 88 minutes   United… English 
##  6 The Rocketeer   <NA>               ['June 21, … 108 minutes  United… English 
##  7 Beauty and the… <NA>               ['September… 84 minutes   United… English 
##  8 Newsies         Walt Disney Pictu… ['April 10,… 121 minutes  United… English 
##  9 Honey, I Blew … ['Walt Disney Pic… ['July 17, … 89 minutes   United… English 
## 10 The Mighty Duc… ['Walt Disney Pic… ['October 2… 104 minutes  United… English 
## # ℹ 56 more rows
## # ℹ 26 more variables: running_time_int <int>, budget_float_in_millions <dbl>,
## #   box_office_float_in_millions <dbl>, release_date_datetime <date>,
## #   imdb <dbl>, metascore <int>, rotten_tomatoes <dbl>, directed_by <chr>,
## #   produced_by <chr>, written_by <chr>, based_on <chr>, starring <chr>,
## #   music_by <chr>, distributed_by <chr>, budget <chr>, box_office <chr>,
## #   story_by <chr>, narrated_by <chr>, cinematography <chr>, edited_by <chr>, …
## 
## [[3]]
## # A tibble: 79 × 32
##    title           production_company release_date running_time country language
##    <chr>           <chr>              <chr>        <chr>        <chr>   <chr>   
##  1 Alice in Wonde… ['Walt Disney Pic… ['February … 108 minutes  United… English 
##  2 Prince of Pers… <NA>               ['May 9, 20… 116 minutes  United… English 
##  3 Toy Story 3     ['Walt Disney Pic… ['June 12, … 103 minutes  United… English 
##  4 The Sorcerer's… ['Walt Disney Pic… ['July 8, 2… 109 minutes  United… English 
##  5 Secretariat     ['Walt Disney Pic… ['September… 123 minutes  United… English 
##  6 Do Dooni Chaar  ['Walt Disney Pic… ['8 October… 108 minutes  India   Hindi   
##  7 Tangled         ['Walt Disney Pic… ['November … 100 minutes  United… English 
##  8 Tron: Legacy    <NA>               ['November … 125 minutes  United… English 
##  9 Lilly the Witc… Walt Disney Pictu… ['17 Februa… 90 minutes   Germany German  
## 10 Mars Needs Moms ['Walt Disney Pic… ['March 11,… 88 minutes   United… English 
## # ℹ 69 more rows
## # ℹ 26 more variables: running_time_int <int>, budget_float_in_millions <dbl>,
## #   box_office_float_in_millions <dbl>, release_date_datetime <date>,
## #   imdb <dbl>, metascore <int>, rotten_tomatoes <dbl>, directed_by <chr>,
## #   produced_by <chr>, written_by <chr>, based_on <chr>, starring <chr>,
## #   music_by <chr>, distributed_by <chr>, budget <chr>, box_office <chr>,
## #   story_by <chr>, narrated_by <chr>, cinematography <chr>, edited_by <chr>, …
## 
## [[4]]
## # A tibble: 13 × 32
##    title           production_company release_date running_time country language
##    <chr>           <chr>              <chr>        <chr>        <chr>   <chr>   
##  1 Timmy Failure:… ['Walt Disney Pic… ['January 2… 99 minutes   United… English 
##  2 Onward          ['Walt Disney Pic… ['February … 102 minutes  United… <NA>    
##  3 Stargirl        ['Walt Disney Pic… ['March 13,… 107 minutes  United… English 
##  4 Elephant        Disneynature       ['April 3, … 89 minutes   United… English 
##  5 Artemis Fowl    ['Walt Disney Pic… ['June 12, … 95 minutes   United… English 
##  6 Hamilton        ['Walt Disney Pic… ['July 3, 2… 160 minutes  United… English 
##  7 Black Is King   ['Parkwood Entert… ['July 31, … 85 minutes   United… English 
##  8 Magic Camp      ['Walt Disney Pic… ['August 14… 100 minutes  United… English 
##  9 The One and On… ['Walt Disney Pic… ['August 21… 95 minutes   United… English 
## 10 Mulan           ['Walt Disney Pic… ['March 9, … 115 minutes  United… English 
## 11 Clouds          <NA>               ['October 1… <NA>         United… English 
## 12 Soul            ['Walt Disney Pic… ['October 1… <NA>         United… English 
## 13 The Beatles: G… <NA>               ['27 August… <NA>         ['Unit… English 
## # ℹ 26 more variables: running_time_int <int>, budget_float_in_millions <dbl>,
## #   box_office_float_in_millions <dbl>, release_date_datetime <date>,
## #   imdb <dbl>, metascore <int>, rotten_tomatoes <dbl>, directed_by <chr>,
## #   produced_by <chr>, written_by <chr>, based_on <chr>, starring <chr>,
## #   music_by <chr>, distributed_by <chr>, budget <chr>, box_office <chr>,
## #   story_by <chr>, narrated_by <chr>, cinematography <chr>, edited_by <chr>,
## #   screenplay_by <chr>, production_companies <chr>, adaptation_by <chr>, …

pluck(): select an element by name or index

      We can use this to select a specific decade dataframe easily.
pluck(laterThan80, '3')
## NULL

Conclusions

      Purrr is a powerful package that helps deal with large amounts of data. As a rule of thumb, think about purrr for use against lists and elements of lists, just as dplyr is for dataframes and rows in dataframes. There are some more transformative options with purrr such as modify, combine, append, and more. I highly recommend looking at these if you are working with dense lists.