-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME.Rmd
60 lines (43 loc) · 1.2 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
<!-- badges: start -->
[![Travis build status](https://travis-ci.org/news-r/loc.svg?branch=master)](https://travis-ci.org/news-r/loc)
<!-- badges: end -->
# 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)
```