Overview

I’ve chosen to pull in the Movie Review API from the New York Times, because I love to read intelligent film opinions. I dropped in the NYT URL and the API key that I registered for.

#NYT API URL with API key appended

api_url <- "https://api.nytimes.com/svc/movies/v2/reviews/picks.json?order=by-publication-date&api-key=0fRcq63AxIjjIAkqWMR9JltIAPSHApmD"

library(rjson)
## Warning: package 'rjson' was built under R version 4.0.3
library(jsonlite)
## Warning: package 'jsonlite' was built under R version 4.0.4
## 
## Attaching package: 'jsonlite'
## The following objects are masked from 'package:rjson':
## 
##     fromJSON, toJSON
# read in JSON data and convert to vector and R objects
json_data <- fromJSON(paste(api_url))
typeof(json_data)
## [1] "list"
#head(json_data$results)

Dataframe exercises

I now need to convert the list into a into a dataframe with the variables that I care about

review_data <- cbind(json_data$results$display_title, json_data$results$byline, json_data$results$summary_short, json_data$results$publication_date)

review_df <- as.data.frame(review_data)
# I'll rename the column names in the new dataframe now

names(review_df)[names(review_df) == "V1"] <- "title"
names(review_df)[names(review_df) == "V2"] <- "byline"
names(review_df)[names(review_df) == "V3"] <- "summary"
names(review_df)[names(review_df) == "V4"] <- "pub_date"

head(review_df)
##                                        title          byline
## 1                                 Shiva Baby    Jason Bailey
## 2                            The Human Voice     Glenn Kenny
## 3 Malni-Towards the Ocean, Towards the Shore Beatrice Loayza
## 4  This Is Not a Burial, It's a Resurrection  Nicolas Rapold
## 5          Miracle Fishing: Kidnapped Abroad  Ben Kenigsberg
## 6                                       Tina     Glenn Kenny
##                                                                                                                                     summary
## 1               The potential land mines of a young woman’s life are set to explode simultaneously in this tense comedy from Emma Seligman.
## 2 The first English-language film from the Spanish director Pedro Almodóvar stars Tilda Swinton and adapts Jean Cocteau to sublime results.
## 3                           This ethereal experimental documentary by Sky Hopinka is an essential portrait of contemporary Indigenous life.
## 4                                                             In this drama, a widow rises out of grief to protest a threat to her village.
## 5                                 The documentary is a unique record of the abduction that inspired the Hollywood thriller “Proof of Life.”
## 6                   The documentary about Tina Turner, who is now in her 80s, is not just a summing up of her life, but a kind of farewell.
##     pub_date
## 1 2021-04-08
## 2 2021-04-01
## 3 2021-04-01
## 4 2021-04-01
## 5 2021-03-25
## 6 2021-03-25

Above, we’ve pulled the reviews of the critics picks sorted by publication date. We can take this and undertake an NLP on the sentiment contained in the summary to try to glean insights on which critics are more harsh than others, if sentiment changes depending on the time of year, etc.

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.