Elina Azrilyan
Week 9 Assignment
Data 607 - Fall 2018
The New York Times web site provides a rich set of APIs, as described here: http://developer.nytimes.com/docs You’ll need to start by signing up for an API key. Your task is to choose one of the New York Times APIs, construct an interface in R to read in the JSON data, and transform it to an R dataframe.
The following script pulls the list of 5 best seller books as of published date 1/1/2017:
library(jsonlite)
library(kableExtra)# manipulate table styles
suppressMessages(library(tidyverse))
## Warning: package 'dplyr' was built under R version 3.5.1
#Code below is adopted from the following webpage https://cran.r-project.org/web/packages/jsonlite/vignettes/json-apis.html)
API_key <- "&api-key=f361bb0197534003a98e682f6c560185"
url <- "http://api.nytimes.com/svc/books/v3/lists/overview.json?published_date=2017-01-01"
req <- fromJSON(paste0(url, API_key))
bestsellers <- req$results$list
category1 <- bestsellers[[1, "books"]]
kable(subset(category1, select = c("author", "title", "publisher", "description")))%>% kable_styling(bootstrap_options = c("striped", "condensed"))
author | title | publisher | description |
---|---|---|---|
John Grisham | THE WHISTLER | Doubleday | A whistleblower alerts a Florida investigator to judicial corruption involving the Mob and Indian casinos. |
James Patterson | CROSS THE LINE | Little, Brown | Detective Alex Cross and his wife, Bree, team up to catch a killer causing chaos in Washington, D.C. |
Fredrik Backman | A MAN CALLED OVE | Washington Square | A curmudgeon’s gruff exterior masks a generosity of spirit. Originally published in Sweden in 2014. |
W Bruce Cameron | A DOG’S PURPOSE | Forge Books | A canine narrator undergoes a series of reincarnations. |
James Rollins | THE SEVENTH PLAGUE | Morrow/HarperCollins | The 12th Sigma Force thriller follows a deadly pathogen in Egypt and a Russian assassin in the Arctic. |
The following pulls a list of 20 critics pick movies:
API_key <- "&api-key=f361bb0197534003a98e682f6c560185"
url <- "https://api.nytimes.com/svc/movies/v2/reviews/search.json?critics-pick=Y"
req <- fromJSON(paste0(url, API_key))
topfilms <- req$results
kable(subset(topfilms, select = c("headline", "summary_short", "display_title", "critics_pick")))%>% kable_styling(bootstrap_options = c("striped", "condensed"))
headline | summary_short | display_title | critics_pick |
---|---|---|---|
Review: In ‘Burning,’ Love Ignites a Divided World | The great South Korean director Lee Chang-dong’s latest involves three characters subsumed by desire and rage. | Burning | 1 |
Review: In ‘A Bread Factory,’ Local Artists Face Off Against the World | An ambitious, sprawling film about the efforts of a community arts center to survive, “A Bread Factory” is a major new work by a singular American artist. | A Bread Factory, Part One | 1 |
Review: In ‘A Bread Factory,’ Local Artists Face Off Against the World | An ambitious, sprawling film about the efforts of a community arts center to survive, “A Bread Factory” is a major new work by a singular American artist. | A Bread Factory, Part Two | 1 |
Review: ‘Monrovia, Indiana’ Is a Sharp, Lyrical Look at Small-Town America | Frederick Wiseman’s visit to Trump country finds that there is more to life than politics, and more to democracy than ideology. | Monrovia, Indiana | 1 |
Review: Sniffing Out Guilt in a Strangely Engaging ‘Border’ | The film, adapted from a short story by the writer of “Let the Right One In,” follows a security guard with an unusual gift. | Border | 1 |
Review: In ‘Shirkers,’ Stolen Footage and Dashed Dreams | Sandi Tan’s captivating documentary about the theft of her first movie by a charismatic con man is both mystery and manhunt. | Shirkers | 1 |
Review: In ‘Vaya,’ Three Travelers Find Danger in Johannesburg | The fate of strangers are darkly intertwined in Akin Omotoso’s electric and empathetic film. | Vaya | 1 |
Review: In ‘1985,’ a Young Man Hides a Plague From His Family | The film is a moving cinematic sketch of a HIV-infected, closeted gay man living through the height of the AIDS crisis. | 1985 | 1 |
Review: ‘Life and Nothing More’ Places Family in the Center | Antonio Méndez Esparza’s keenly observed indie alludes to many hot-button issues but keeps them largely in the background. | Life & Nothing More | 1 |
Review: In ‘Wildlife,’ Passions Run Rampant | The film, directed by Paul Dano and starring Carey Mulligan and Jake Gyllenhaal, is a domestic drama both sad and terrifying. | Wildlife | 1 |
Review: Bright Young Men Stoop to Scam in ‘Nigerian Prince’ | This engaging debut feature film by Faraday Okoro asks if there is an honest way for young people to thrive in a country like today’s Nigeria. | Nigerian Prince | 1 |
Review: ‘On Her Shoulders’ Follows Nobel Peace Prize Winner Nadia Murad | The documentary spotlights the hope and weariness of Murad, who was held captive by the Islamic State in Northern Iraq. | On Her Shoulders | 1 |
Review: ‘The Guilty’ Places a Troubled Police Officer on Hold | Gustav Moller’s ingeniously lean thriller builds tension from little more than one police officer, two rooms and a frantic telephone call from a kidnapped woman. | The Guilty | 1 |
‘Halloween’ 1978: The Times Finally Reviews a Horror Classic | We didn’t review “Halloween” in 1978 because of a newspaper strike. Forty years later, our critic takes a new look at John Carpenter’s masterpiece. | Halloween | 1 |
Review: A Restless Spirit Haunts a Family in ‘A Season in France’ | Dangerous uncertainty, and a bit of hope, hangs over a family seeking political asylum in Mahamat-Saleh Haroun’s latest feature. | A Season in France | 1 |
Review: Melissa McCarthy Is Criminally Good in ‘Can You Ever Forgive Me?’ | Marielle Heller directs a true story of literary fraud, set amid the bookstores and gay bars of early ’90s Manhattan. | Can You Ever Forgive Me | 1 |
Review: ‘Charm City’ Vividly Captures the Streets of Baltimore | Marilyn Ness’s documentary is dedicated to the memory of the more than 1,000 people said to be killed in Baltimore during the film’s making. | Charm City | 1 |
Review: Paul Butterfield’s Story Is Told in ‘Horn From the Heart’ | A documentary explores the life of the blues musician who was prominent in the 1960s and ’70s. | Horn from the Heart: The Paul Butterfield Story | 1 |
Review: ‘Watergate’ Shocks Anew With Its True Tale of Political Scandal | Charles Ferguson delivers a comprehensive documentary about the not-so-distant past, with its eye very much on the present. | Watergate | 1 |
Review: In ‘Barbara,’ a Fictional Biopic of a French Chanteuse | It’s a film of scenes rather than of one unified narrative, but each scene is a showcase for the magnificent talents of its star. | Barbara | 1 |