knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

Travis build status

loc

Access the Library of Congress from R.

Chronicling America provides access [140,000] historic newspapers and select digitized newspaper pages.

Installation

# install.packages("remotes")
remotes::install_github("news-r/loc")

Example

library(loc)

# titles
titles <- loc_search_titles("michigan", pages = 2)

# pages
(articles <- loc_search_pages("Thomas"))

The text of the newspaper is in the ocr_eng variable. You can reconstruct endpoints to specific newspapers, editions, or issues.

a <- sample(articles$url, 1) # take a random article
pdf <- gsub(".json", ".pdf", a) # change to PDF
# browseURL(pdf)

And you can get the text with:

txt <- gsub(".json", "/ocr.txt", a) # change to PDF
readLines(txt)


news-r/loc documentation built on Aug. 15, 2024, 12:14 p.m.