pacman::p_load(httr, jsonlite, dplyr, tidyr, stringr, ggplot2)
query <- "https://api.nytimes.com/svc/mostpopular/v2/emailed/7.json?api-key=uMkO2TnZWMpNQp8VBvcKn0AXAUeDSJZA"
data <- fromJSON(query)
json_data <- as.data.frame(data)
View(json_data)
df <- count(json_data, results.nytdsection)
ggplot(df, aes(x=reorder(results.nytdsection, n),
y=n, label="count")) +
geom_bar(stat='identity', width=.5, fill = "lightblue", color = "darkblue") +
scale_fill_manual(name="Article Type") +
labs(title= "Article Type") +
coord_flip()
df <- count(json_data, results.published_date)
ggplot(df, aes(x=reorder(results.published_date, results.published_date),
y=n, label="count")) +
geom_bar(stat='identity', width=.5, fill = "lightblue", color = "darkblue") +
scale_fill_manual(name="Published Articles by Date") +
labs(title= "Published Articles by Date")