R Markdown

The New York Times website provides a rich set of API’s, as described here: https://developer.nytimes.com/apis. 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 into an R dataframe.

##Step 1: Sign up for an API key and read in a site key. I tried several paths as listed on the books API site and this is the only one that seemed to work for me.

options(stringsAsFactors = FALSE)
library(jsonlite)
library(DT)
url <- "https://api.nytimes.com/svc/books/v3/lists/best-sellers/history.json?api-key=XUZGmiWXNo5rQJQgZ2blEiWymUtz0FGT"
df <- fromJSON(url, flatten = TRUE)
datatable(df$results)

Including Plots

You can also embed plots, for example:

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