https://github.com/news-r/loc
📚 R wrapper to the Library of Congress APIs
https://github.com/news-r/loc
library-of-congress r rstats
Last synced: 14 days ago
JSON representation
📚 R wrapper to the Library of Congress APIs
- Host: GitHub
- URL: https://github.com/news-r/loc
- Owner: news-r
- License: other
- Created: 2019-06-03T18:24:54.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-08-11T21:19:48.000Z (8 months ago)
- Last Synced: 2025-03-20T16:51:17.527Z (26 days ago)
- Topics: library-of-congress, r, rstats
- Language: R
- Homepage:
- Size: 919 KB
- Stars: 6
- Watchers: 0
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - news-r/loc - 📚 R wrapper to the Library of Congress APIs (R)
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```[](https://travis-ci.org/news-r/loc)
# loc
Access the [Library of Congress](https://chroniclingamerica.loc.gov) from R.
> Chronicling America provides access [140,000] historic newspapers and select digitized newspaper pages.
## Installation
``` r
# install.packages("remotes")
remotes::install_github("news-r/loc")
```## Example
```{r}
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.
```{r}
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:
```{r}
txt <- gsub(".json", "/ocr.txt", a) # change to PDF
readLines(txt)
```