knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The goal of sul.wp is to help Stanford researchers access the Library's collection of Washington Post Full-Text Archives through R
install.packages("devtools") devtools::install_github("wrathofquan/sul.wp")
First log in to redivis.com with your SUNet ID. Then create your API token:
library(sul.wp) ## Authenticate with Redivis ## More on Redivis API: https://apidocs.redivis.com/authorization # redivis_auth("your-api-token")
## Get an entire year of articles df_1977 <- get_articles_year("1977") head(df_1977) dim(df_1977)
## To get multiple years of articles, you can use purrr, apply, or a 'for' loop. ## Example using purrr: years <- c("1977", "1980") df_twoYears <- purrr::map_dfr(years, get_articles_year) dim(df_twoYears)
## Search title and paragraphs of articles using case-insensitive keyword, restrict by year, remove <html> formatting from articles ## Note that some articles are assets like embedded videos or image slide-shows ## use of strip_html will likely return empty strings for these types of content. df_blm <- search_articles(query = "Black Lives Matter", year = "2016", strip_html = TRUE) head(df_blm)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.