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 code accesses the New York Times Book Reviews for the author Lee Child, and stores them in a dataframe in R.
library(jsonlite)
## Warning: package 'jsonlite' was built under R version 3.2.2
##
## Attaching package: 'jsonlite'
##
## The following object is masked from 'package:utils':
##
## View
nyt_book_key <- "&api-key=15c2827997f9e1400c5cc5cd88af8111:7:73337648" ## store the api key so the API can be accessed
url <- "http://api.nytimes.com/svc/books/v3/reviews.json?author=Lee%20Child" ## web address to access using author name
book_review_request <- fromJSON(paste0(url, nyt_book_key)) ## make the request, submit the API key and bring info into r
lee_child_nyt_book_reviews <- book_review_request$results ## store the results, culling extraneous info
head(lee_child_nyt_book_reviews, 2) ## View the first 2 rows of the data frame
## url
## 1 http://www.nytimes.com/2012/09/10/books/a-wanted-man-a-jack-reacher-novel-by-lee-child.html
## 2 http://www.nytimes.com/2013/08/30/books/never-go-back-a-jack-reacher-novel-by-lee-child.html
## publication_dt byline book_title book_author
## 1 2012-09-10 JANET MASLIN Wanted Man Lee Child
## 2 2013-08-30 JANET MASLIN Never Go Back Lee Child
## summary
## 1 <U+0093>A Wanted Man<U+0094> is Lee Child<U+0092>s 17th Jack Reacher novel and the last to be published before Reacher goes Hollywood with a big Christmas movie.
## 2 Jack Reacher returns in Lee Child<U+0092>s <U+0093>Never Go Back<U+0094> for a cross-country pursuit full of surprises and a possible love child.
## isbn13
## 1 9780307749581, 9780307749604, 9780307990853, 9780385344333, 9780440246312, 9780440339366, 9780804148924, 9781409043560
## 2 9780440246329
lee_child_nyt_book_reviews[c("book_title", "summary")] ## View 2 columns of interest from the data frame
## book_title
## 1 Wanted Man
## 2 Never Go Back
## 3 The Affair
## 4 61 Hours
## 5 Nothing to Lose
## 6 Bad Luck and Trouble
## 7 The Hard Way
## 8 Running Blind
## 9 The Enemy (Jack Reacher, No. 8)
## 10 One Shot (Jack Reacher, No. 9)
## summary
## 1 <U+0093>A Wanted Man<U+0094> is Lee Child<U+0092>s 17th Jack Reacher novel and the last to be published before Reacher goes Hollywood with a big Christmas movie.
## 2 Jack Reacher returns in Lee Child<U+0092>s <U+0093>Never Go Back<U+0094> for a cross-country pursuit full of surprises and a possible love child.
## 3 In <U+0093>The Affair,<U+0094> the 16th book in the Reacher series, Lee Child gives his hero a back story.
## 4 Lee Child<U+0092>s tough, cerebral hero Jack Reacher returns in a thriller that finds him snowbound in South Dakota.
## 5 Leaves turn. Snow falls. Robins tweet. And a new Jack Reacher novel arrives as the year<U+0092>s first red-hot beach book.
## 6 <U+0093>Bad Luck and Trouble<U+0094> unfolds with the simple, immaculate logic that makes Lee Child<U+0092>s Jack Reacher series utterly addictive.
## 7 Big, smart, occasionally wrong, Jack Reacher returns for a 10th adventure.
## 8
## 9
## 10