An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

        

---
output: github_document
---

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

[![Travis build status](https://travis-ci.org/news-r/loc.svg?branch=master)](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)
```

![](loc.png)

And you can get the text with:

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