class: center, middle, inverse, title-slide # ETC1010: Data Modelling and Computing ## Lecture 6B: Functions ### Dr. Nicholas Tierney & Professor Di Cook ### EBS, Monash U. ### 2019-09-06 --- class: bg-main1 # Recap .huge[ - style (it's important!) - ed quiz ] --- class: bg-main3 # File Paths and organising yourself .huge[ - It's important when you start working on your own machine that you understand _file storage hygiene_. - It helps prevent unexpected problems and makes you more productive - You'll spend less time fighting against strange file paths. - Not sure what a file path is? We'll explain that as well. ] --- class: bg-main1 # Your Turn .huge[ Discuss: 1. What your normal "workflow" is for starting a new project 2. Possible challenges that might arise when maintaining your project ] --- class: bg-main1 # A Mantra: When you start a new project \- Open a new RStudio project .huge[ - This section is heavily influenced by [Jenny Bryan's great blog post on project based workflows.](https://www.tidyverse.org/articles/2017/12/workflow-vs-script/) - Sometimes this is the first line of an R Script or R markdown file. ```r setwd("c:/really/long/file/path/to/this/directory) ``` - What do you think the `setwd` code does? ] --- class: bg-main1 # What does `setwd()` do? .huge[ - "set my working directory to this specific working directory". - It means that you can read in data and other things like this: ```r data <- read_csv("data/mydata.csv") ``` - Instead of ```r data <- read_csv("c:/really/long/file/path/to/this/directory/data/mydata.csv") ``` ] --- class: bg-main1 # What does `setwd()` do? .huge[ - This has the effect of **making the file paths work in your file** - This is a problem because, among other things, using `setwd()` like this: - Has 0% chance of working on someone else's machine (**this includes you in >6 months**) - Your file is not self-contained and portable. (Think: _"What if this folder moved to /Downloads, or onto another machine?"_) - To get this to work, you need to hand edit the file path to your machine. - This is painful. And when you do this all the time, it gets old, fast. ] --- class: bg-main1 # What even is a file path? .huge[ - The machine-readable directions to where files on your computer live. - So, this file path: ``` /Users/njtierney/rmd4sci-materials/demo-gapminder.Rmd ``` Describes the location of the file "demo-gapminder.Rmd". ] --- class: bg-main1 # What even is a file path? .huge[ We could visualise the path ``` /Users/njtierney/rmd4sci-materials/demo-gapminder.Rmd ``` as: ``` users └── njtierney └── rmd4sci-materials └── demo-gapminder.Rmd ``` ] --- class: bg-main1 .huge[ - To read in the `gapminder.csv` file, you might need to write code like this: ```r gapminder <- read_csv("/Users/njtierney/Desktop/rmd4sci-materials/data/gapminder.csv") ``` This is a problem, because this is not portable code. ] -- .huge[ It has ZERO chance of working on someone else's machine ] --- class: bg-main1 .huge[ If you have an RStudio project file inside the `rmd4sci-materials` folder, you can instead write the following: ```r gapminder <- read_csv("data/gapminder.csv") ``` ] --- class: bg-main1 # Your Turn .vlarge[ - What folders are above the `health.csv` file in the following given file path? `"/Users/miles/etc1010/week1/data/health.csv"` - What would be the result of using the following code in `demo-gapminder.Rmd`, and then using the code, and then moving this to another location, say inside your C drive? ```r setwd("Downloads/etc1010/week1/week1.Rmd) ``` ] --- class: bg-main1 # Is there an answer to the madness? .huge[ - This file path situation is a real pain. ] -- .huge[ Yes! When you start on a new idea, new research project, paper... Anything new. It should start its life as an **rstudio project**. ] --- class: bg-main1 # One more time: say it with me .vhuge[ When you start on a new idea, new research project, paper... Anything new. It should start its life as an **rstudio project**. ] --- class: bg-main1 # Demo --- class: bg-main1 # Rstudio projects help keep related work together in the same place. .huge[ * Keep all your files together * Set the working directory to the project directory * Starts a new session of R * Restore previously edited files into the editor tabs * Restore other rstudio settings * Allow for multiple R projects open at the same time. ] --- class: bg-main1 # Rstudio projects help keep you sane, because: .huge[ * Projects are independent. * You can work on different projects at the same time. * Objects & functions created in one project won't impact another. * You can refer to your data and other projects in a consistent way. ] --- class: bg-main1 # Rstudio projects help keep you sane, because: .huge[ And finally, the big one **RStudio projects help resolve file path problems**, because they automatically set the working directory to the location of the rstudio project. ] --- class: bg-main1 # A Bit more on file paths --- class: bg-main1 # The "here" package .huge[ - RStudio projects help resolve file path problems - In some cases you might have many folders in your r project. To help navigate them appropriately, you can use the `here` package to provide the full path directory, in a compact way. ```r here::here("exercise") ``` ``` ## [1] "/Users/ntie0001/github/njtierney/Data_Modelling_and_Computing/static/lectures/exercise" ``` ] --- class: bg-main1 # The `here` package .huge[ ```r here::here("exercise", "lecture-6b-exercise.Rmd") ``` ``` ## [1] "/Users/ntie0001/github/njtierney/Data_Modelling_and_Computing/static/lectures/exercise/lecture-6b-exercise.Rmd" ``` ] --- class: bg-main1 .huge[ ```r here::here("exercise", "lecture-6b-exercise.Rmd") ``` You can read the above `here` code as: > In the folder `exercise`, there is a file called `lecture-6b-exercise.Rmd`. Can you please give me the full path to that file? ] --- class: bg-main1 # The `here` package .huge[ This is really handy for a few reasons: 1. It makes file paths _completely_ portable 1. Rmarkdown documents have a special way of looking for files, this helps eliminate file path pain. 1. If you decide to not use RStudio projects, you have code that will work on _any machine_ ] --- class: bg-main1 # Remember .huge[ > If the first line of your R script is ``` setwd("C:\Users\jenny\path\that\only\I\have") ``` > I will come into your office and SET YOUR COMPUTER ON FIRE 🔥. -- Jenny Bryan ] --- class: bg-main1 # Aside: How to create an RStudio project .huge[ - Go to [section 5.12 of rmarkdown for scientists](https://rmd4sci.njtierney.com/workflow.html#aside-creating-an-rstudio-project) ] --- class: bg-main1 # Summary of file paths and rstudio projects .huge[ So far we have: * Learnt what file paths are * How to setup an rstudio project * How to construct full file paths with the `here` package ] --- class: bg-main1 # Go to ed and finish quiz 6b --- class: bg-main1 # Motivating Functions --- class: bg-main1 # Remember web scraping? <img src="https://m.media-amazon.com/images/M/MV5BZGExYjQzNTQtNGNhMi00YmY1LTlhY2MtMTRjODg3MjU4YTAyXkEyXkFqcGdeQXVyMTkxNjUyNQ@@._V1_.jpg" width="40%" style="display: block; margin: auto;" /> --- class: bg-main1 # How many episodes are there of Stranger Things? ```r st_episode <- bow("https://www.imdb.com/title/tt4574334/") %>% scrape() %>% html_nodes(".np_right_arrow .bp_sub_heading") %>% html_text() %>% str_remove(" episodes") %>% as.numeric() st_episode ``` ``` ## [1] 25 ``` --- class: bg-main1 # How many episodes of stranger things? And ... Mindhunter? ```r st_episode <- bow("https://www.imdb.com/title/tt4574334/") %>% scrape() %>% html_nodes(".np_right_arrow .bp_sub_heading") %>% html_text() %>% str_remove(" episodes") %>% as.numeric() st_episode ``` ``` ## [1] 25 ``` ```r mh_episodes <- bow("https://www.imdb.com/title/tt4574334/") %>% scrape() %>% html_nodes(".np_right_arrow .bp_sub_heading") %>% html_text() %>% str_remove(" episodes") %>% as.numeric() mh_episodes ``` ``` ## [1] 25 ``` --- class: bg-main1 # Why functions? .huge[ - Automate common tasks in a power powerful and general way than copy-and-pasting: - Give a functions an evocative name that makes code easier to understand. - As requirements change, **you only need to update code in one place, instead of many**. - You eliminate the chance of making incidental mistakes when you copy and paste (i.e. updating a variable name in one place, but not in another). ] --- class: bg-main1 # Why functions? .huge[ - Down the line: Improve your reach as a data scientist by writing functions (and packages!) that others use ] --- class: bg-main1 # Setup ```r library(tidyverse) library(rvest) library(polite) st <- bow("http://www.imdb.com/title/tt4574334/") %>% scrape() twd <- bow("http://www.imdb.com/title/tt1520211/") %>% scrape() got <- bow("http://www.imdb.com/title/tt0944947/") %>% scrape() ``` --- class: bg-main1 # When should you write a function? .huge[ Whenever you’ve copied and pasted a block of code more than twice. When you want to clearly express some set of actions (there are many other reasons as well!) ] --- class: bg-main1 # Do you see any problems in the code below? ```r st_episode <- st %>% html_nodes(".np_right_arrow .bp_sub_heading") %>% html_text() %>% str_replace(" episodes", "") %>% as.numeric() got_episode <- got %>% html_nodes(".np_right_arrow .bp_sub_heading") %>% html_text() %>% str_replace(" episodes", "") %>% as.numeric() twd_episode <- got %>% html_nodes(".np_right_arrow .bp_sub_heading") %>% html_text() %>% str_replace(" episodes", "") %>% as.numeric() ``` --- class: bg-main1 # Inputs .huge[ How many inputs does the following code have? ] ```r st_episode <- st %>% html_nodes(".np_right_arrow .bp_sub_heading") %>% html_text() %>% str_replace(" episodes", "") %>% as.numeric() ``` --- class: bg-main1 # Turn the code into a function .vlarge[ Pick a short but informative **name**, preferably a verb. ] <br> <br> <br> <br> ```r scrape_episode <- ``` --- class: bg-main1 # Turn your code into a function .vlarge[ - Pick a short but informative **name**, preferably a verb. - List inputs, or **arguments**, to the function inside `function`. If we had more the call would look like `function(x, y, z)`. ] <br> ```r scrape_episode <- function(x){ } ``` --- class: bg-main1 # Turn your code into a function .vlarge[ - Pick a short but informative **name**, preferably a verb. - List inputs, or **arguments**, to the function inside `function`. If we had more the call would look like `function(x, y, z)`. - Place the **code** you have developed in body of the function, a `{` block that immediately follows `function(...)`. ] ```r scrape_episode <- function(x){ x %>% html_nodes(".np_right_arrow .bp_sub_heading") %>% html_text() %>% str_replace(" episodes", "") %>% as.numeric() } ``` --- class: bg-main1 # Turn your code into a function ```r scrape_episode <- function(x){ x %>% html_nodes(".np_right_arrow .bp_sub_heading") %>% html_text() %>% str_replace(" episodes", "") %>% as.numeric() } ``` ```r scrape_episode(st) ``` ``` ## [1] 25 ``` --- class: bg-main1 # Check your function .huge[ - Number of episodes in The Walking Dead ] ```r scrape_episode(twd) ``` ``` ## [1] 147 ``` .huge[ - Number of episodes in Game of Thrones ] ```r scrape_episode(got) ``` ``` ## [1] 73 ``` --- class: bg-main1 # Naming functions (it's hard) .huge[ > "There are only two hard things in Computer Science: cache invalidation and naming things." - Phil Karlton ] --- class: bg-main1 # Naming functions (it's hard) .huge[ - Names should be short but clearly evoke what the function does ] -- .huge[ - Names should be verbs, not nouns ] -- .huge[ - Multi-word names should be separated by underscores (`snake_case` as opposed to `camelCase`) ] --- class: bg-main1 # Naming functions (it's hard!) .huge[ - A family of functions should be named similarly (`scrape_title`, `scrape_episode`, `scrape_genre`, etc.) ] -- .huge[ - Avoid overwriting existing (especially widely used) functions (e.g., `ggplot`) ] --- class: bg-main1 # Scraping show info ```r scrape_show_info <- function(x){ title <- x %>% html_node("#title-overview-widget h1") %>% html_text() %>% str_trim() runtime <- x %>% html_node("time") %>% html_text() %>% str_replace("\\n", "") %>% str_trim() genres <- x %>% html_nodes(".txt-block~ .canwrap a") %>% html_text() %>% str_trim() %>% paste(collapse = ", ") tibble(title = title, runtime = runtime, genres = genres) } ``` --- class: bg-main1 ```r scrape_show_info(st) ``` ``` ## # A tibble: 1 x 3 ## title runtime genres ## <chr> <chr> <chr> ## 1 Stranger Things 51min Drama, Fantasy, Horror, Mystery, Sci-Fi, Thriller ``` ```r scrape_show_info(twd) ``` ``` ## # A tibble: 1 x 3 ## title runtime genres ## <chr> <chr> <chr> ## 1 The Walking Dead 44min Drama, Horror, Thriller ``` --- class: bg-main1 # How to update this function to use page URL as argument? ```r scrape_show_info <- function(x){ title <- x %>% html_node("#title-overview-widget h1") %>% html_text() %>% str_trim() runtime <- x %>% html_node("time") %>% html_text() %>% str_replace("\\n", "") %>% str_trim() genres <- x %>% html_nodes(".txt-block~ .canwrap a") %>% html_text() %>% str_trim() %>% paste(collapse = ", ") tibble(title = title, runtime = runtime, genres = genres) } ``` --- class: bg-main1 ```r scrape_show_info <- function(x){ y <- bow(x) %>% scrape() title <- y %>% html_node("#title-overview-widget h1") %>% html_text() %>% str_trim() runtime <- y %>% html_node("time") %>% html_text() %>% str_replace("\\n", "") %>% str_trim() genres <- y %>% html_nodes(".txt-block~ .canwrap a") %>% html_text() %>% str_trim() %>% paste(collapse = ", ") tibble(title = title, runtime = runtime, genres = genres) } ``` --- class: bg-main1 ## Let's check ```r st_url <- "http://www.imdb.com/title/tt4574334/" twd_url <- "http://www.imdb.com/title/tt1520211/" ``` -- ```r scrape_show_info(st_url) ``` ``` ## # A tibble: 1 x 3 ## title runtime genres ## <chr> <chr> <chr> ## 1 Stranger Things 51min Drama, Fantasy, Horror, Mystery, Sci-Fi, Thriller ``` ```r scrape_show_info(twd_url) ``` ``` ## # A tibble: 1 x 3 ## title runtime genres ## <chr> <chr> <chr> ## 1 The Walking Dead 44min Drama, Horror, Thriller ``` --- class: center, middle # Automation --- class: bg-main1 .huge[ - You now have a function that will scrape the relevant info on shows given its URL. - Where can we get a list of URLs of top 100 most popular TV shows on IMDB? - Write the code for doing this in your teams. ] --- class: bg-main1 ```r urls <- bow("http://www.imdb.com/chart/tvmeter") %>% scrape() %>% html_nodes(".titleColumn a") %>% html_attr("href") %>% paste("http://www.imdb.com", ., sep = "") ``` ``` ## [1] "http://www.imdb.com/title/tt1837492/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_1" ## [2] "http://www.imdb.com/title/tt5290382/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_2" ## [3] "http://www.imdb.com/title/tt2442560/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_3" ## [4] "http://www.imdb.com/title/tt8111088/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_4" ## [5] "http://www.imdb.com/title/tt1190634/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_5" ## [6] "http://www.imdb.com/title/tt0489974/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_6" ## [7] "http://www.imdb.com/title/tt6905542/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_7" ## [8] "http://www.imdb.com/title/tt4574334/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_8" ## [9] "http://www.imdb.com/title/tt8634332/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_9" ## [10] "http://www.imdb.com/title/tt0903747/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_10" ## [11] "http://www.imdb.com/title/tt0944947/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_11" ## [12] "http://www.imdb.com/title/tt5834204/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_12" ## [13] "http://www.imdb.com/title/tt6468322/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_13" ## [14] "http://www.imdb.com/title/tt4236770/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_14" ## [15] "http://www.imdb.com/title/tt8772296/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_15" ## [16] "http://www.imdb.com/title/tt3281796/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_16" ## [17] "http://www.imdb.com/title/tt2372162/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_17" ## [18] "http://www.imdb.com/title/tt1632701/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_18" ## [19] "http://www.imdb.com/title/tt2085059/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_19" ## [20] "http://www.imdb.com/title/tt7660850/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_20" ## [21] "http://www.imdb.com/title/tt2661044/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_21" ## [22] "http://www.imdb.com/title/tt0386676/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_22" ## [23] "http://www.imdb.com/title/tt0108778/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_23" ## [24] "http://www.imdb.com/title/tt6077448/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_24" ## [25] "http://www.imdb.com/title/tt1844624/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_25" ## [26] "http://www.imdb.com/title/tt8285216/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_26" ## [27] "http://www.imdb.com/title/tt7366338/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_27" ## [28] "http://www.imdb.com/title/tt5770786/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_28" ## [29] "http://www.imdb.com/title/tt1520211/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_29" ## [30] "http://www.imdb.com/title/tt4052886/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_30" ## [31] "http://www.imdb.com/title/tt9174582/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_31" ## [32] "http://www.imdb.com/title/tt0460681/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_32" ## [33] "http://www.imdb.com/title/tt3006802/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_33" ## [34] "http://www.imdb.com/title/tt5753856/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_34" ## [35] "http://www.imdb.com/title/tt0412253/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_35" ## [36] "http://www.imdb.com/title/tt2699110/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_36" ## [37] "http://www.imdb.com/title/tt2306299/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_37" ## [38] "http://www.imdb.com/title/tt0413573/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_38" ## [39] "http://www.imdb.com/title/tt6048596/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_39" ## [40] "http://www.imdb.com/title/tt0898266/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_40" ## [41] "http://www.imdb.com/title/tt1043813/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_41" ## [42] "http://www.imdb.com/title/tt8652642/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_42" ## [43] "http://www.imdb.com/title/tt2467372/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_43" ## [44] "http://www.imdb.com/title/tt8369840/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_44" ## [45] "http://www.imdb.com/title/tt6398232/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_45" ## [46] "http://www.imdb.com/title/tt8179162/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_46" ## [47] "http://www.imdb.com/title/tt0452046/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_47" ## [48] "http://www.imdb.com/title/tt8685324/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_48" ## [49] "http://www.imdb.com/title/tt3032476/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_49" ## [50] "http://www.imdb.com/title/tt2708480/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_50" ## [51] "http://www.imdb.com/title/tt2891574/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_51" ## [52] "http://www.imdb.com/title/tt4955642/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_52" ## [53] "http://www.imdb.com/title/tt1606375/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_53" ## [54] "http://www.imdb.com/title/tt1327801/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_54" ## [55] "http://www.imdb.com/title/tt3920596/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_55" ## [56] "http://www.imdb.com/title/tt0364845/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_56" ## [57] "http://www.imdb.com/title/tt5057054/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_57" ## [58] "http://www.imdb.com/title/tt5016504/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_58" ## [59] "http://www.imdb.com/title/tt5574490/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_59" ## [60] "http://www.imdb.com/title/tt0475784/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_60" ## [61] "http://www.imdb.com/title/tt0203259/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_61" ## [62] "http://www.imdb.com/title/tt2741602/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_62" ## [63] "http://www.imdb.com/title/tt4158110/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_63" ## [64] "http://www.imdb.com/title/tt2356777/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_64" ## [65] "http://www.imdb.com/title/tt3566726/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_65" ## [66] "http://www.imdb.com/title/tt0118401/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_66" ## [67] "http://www.imdb.com/title/tt5296406/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_67" ## [68] "http://www.imdb.com/title/tt0098749/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_68" ## [69] "http://www.imdb.com/title/tt3743822/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_69" ## [70] "http://www.imdb.com/title/tt3636060/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_70" ## [71] "http://www.imdb.com/title/tt8022928/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_71" ## [72] "http://www.imdb.com/title/tt0141842/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_72" ## [73] "http://www.imdb.com/title/tt5420376/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_73" ## [74] "http://www.imdb.com/title/tt4124758/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_74" ## [75] "http://www.imdb.com/title/tt2364582/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_75" ## [76] "http://www.imdb.com/title/tt2193021/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_76" ## [77] "http://www.imdb.com/title/tt9208876/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_77" ## [78] "http://www.imdb.com/title/tt1586680/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_78" ## [79] "http://www.imdb.com/title/tt0472954/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_79" ## [80] "http://www.imdb.com/title/tt0804503/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_80" ## [81] "http://www.imdb.com/title/tt6143796/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_81" ## [82] "http://www.imdb.com/title/tt0460649/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_82" ## [83] "http://www.imdb.com/title/tt1064899/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_83" ## [84] "http://www.imdb.com/title/tt0436992/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_84" ## [85] "http://www.imdb.com/title/tt7671068/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_85" ## [86] "http://www.imdb.com/title/tt2802850/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_86" ## [87] "http://www.imdb.com/title/tt3526078/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_87" ## [88] "http://www.imdb.com/title/tt3107288/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_88" ## [89] "http://www.imdb.com/title/tt1266020/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_89" ## [90] "http://www.imdb.com/title/tt0412142/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_90" ## [91] "http://www.imdb.com/title/tt5071412/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_91" ## [92] "http://www.imdb.com/title/tt1124373/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_92" ## [93] "http://www.imdb.com/title/tt8425532/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_93" ## [94] "http://www.imdb.com/title/tt5180504/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_94" ## [95] "http://www.imdb.com/title/tt2861424/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_95" ## [96] "http://www.imdb.com/title/tt4786824/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_96" ## [97] "http://www.imdb.com/title/tt1796960/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_97" ## [98] "http://www.imdb.com/title/tt3230854/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_98" ## [99] "http://www.imdb.com/title/tt9054904/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_99" ## [100] "http://www.imdb.com/title/tt1869454/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=332cb927-0342-42b3-815c-f9124e84021d&pf_rd_r=MZW2CP8ZEQDRJHHGNW50&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=tvmeter&ref_=chttvm_tt_100" ``` --- class: bg-main1 # Go to each page, scrape show info .vlarge[ - Now we need a way to programatically direct R to each page on the `urls` list and run the `scrape_show_info` function on that page. ] ```r scrape_show_info(urls[1]) ``` ``` ## # A tibble: 1 x 3 ## title runtime genres ## <chr> <chr> <chr> ## 1 13 Reasons Why 1h Drama, Mystery ``` ```r scrape_show_info(urls[2]) ``` ``` ## # A tibble: 1 x 3 ## title runtime genres ## <chr> <chr> <chr> ## 1 Mindhunter 1h Crime, Drama, Thriller ``` ```r scrape_show_info(urls[3]) ``` ``` ## # A tibble: 1 x 3 ## title runtime genres ## <chr> <chr> <chr> ## 1 Peaky Blinders 1h Crime, Drama ``` --- class: bg-main1 # Go to each page, scrape show info .huge[ In other words, we want to **map** the `scrape_show_info` function to each element of `show_urls`: ] ```r top_100_shows <- map_df(urls, scrape_show_info) ``` .huge[ - This will hit the `urls` one after another, and grab the info. ] --- class: bg-main1 # Passing functions to ... functions? .huge[ - The fact that we can pass a function to another is a **big idea**, and is one of the things that makes R a **functional programming language**. - It's a bit mind-bending, but it's an idea worth practicing and comfortable with ] --- class: bg-main1 # aside: `list`s as an idea: first...vectors .huge[ - `c()` creates a **vector** of one type - e.g., `x <- c(1, 2, 3, "A")` contains: - `[1] "1" "2" "3" "A"` - `class(x)` returns: - `[1] "character"` ] --- class: bg-main1 # aside: `list`s as an idea: first...vectors .huge[ - You can look up vectors based on position with `[]` - `x[1]` returns the first thing - `x[2]` returns the second thing - `x[1:2]` returns the first through to second thing ] --- class: bg-main1 # aside: `list`s as an idea: second...lists .huge[ - `list()` creates list, which can be any type ```r y <- list(1,2,3,"x"); y #> [[1]] #> [1] 1 #> #> [[2]] #> [1] 2 #> #> [[3]] #> [1] 3 #> #> [[4]] #> [1] "x" ``` ] --- class: bg-main1 # aside: `list`s as an idea: second...lists .huge[ - You access positions of a list with `[[]]` - So `y[[1]]` returns: `1` ] --- class: bg-main1 # aside: a `data frame` is actually a list! --- class: bg-main1 # calculate the mean for every column: ```r map(mtcars, mean) ``` ``` ## $mpg ## [1] 20.09062 ## ## $cyl ## [1] 6.1875 ## ## $disp ## [1] 230.7219 ## ## $hp ## [1] 146.6875 ## ## $drat ## [1] 3.596563 ## ## $wt ## [1] 3.21725 ## ## $qsec ## [1] 17.84875 ## ## $vs ## [1] 0.4375 ## ## $am ## [1] 0.40625 ## ## $gear ## [1] 3.6875 ## ## $carb ## [1] 2.8125 ``` --- class: bg-main1 # calculate the mean for every column: ```r map_dbl(mtcars, mean) ``` ``` ## mpg cyl disp hp drat wt qsec vs ## 20.090625 6.187500 230.721875 146.687500 3.596563 3.217250 17.848750 0.437500 ## am gear carb ## 0.406250 3.687500 2.812500 ``` --- class: bg-main1 # Range for every column: writing a function ```r my_range <- function(x){ max(x) - min(x) } map_dbl(mtcars, my_range) ``` ``` ## mpg cyl disp hp drat wt qsec vs am gear carb ## 23.500 4.000 400.900 283.000 2.170 3.911 8.400 1.000 1.000 2.000 7.000 ``` --- class: bg-main1 # Range for every column: writing a function in map ```r map_dbl(mtcars, .f = function(x) max(x) - min(x)) ``` ``` ## mpg cyl disp hp drat wt qsec vs am gear carb ## 23.500 4.000 400.900 283.000 2.170 3.911 8.400 1.000 1.000 2.000 7.000 ``` --- class: bg-main1 # Range for every column: writing a function in map ```r map_dbl(mtcars, .f = ~(max(.) - min(.))) ``` ``` ## mpg cyl disp hp drat wt qsec vs am gear carb ## 23.500 4.000 400.900 283.000 2.170 3.911 8.400 1.000 1.000 2.000 7.000 ``` --- class: bg-main1 # Your Turn: rstudio.cloud .huge[ Take the lab quiz! ] --- class: bg-main1 # Resources .huge[ - Jenny Bryans blog post - functions chapter of r4DS - iteration section of r4ds - [lists section in advanced R](https://adv-r.hadley.nz/vectors-chap.html#lists) ] --- class: bg-main1 # Share and share alike <a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>.