-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME.Rmd
103 lines (68 loc) · 2.04 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# timetravelr
```{r, echo=FALSE}
knitr::opts_chunk$set(
comment = "#>",
collapse = TRUE,
warning = FALSE,
message = FALSE
)
```
## About
timetravelr is an R Client for the [Memento Time Travel API](http://timetravel.mementoweb.org/about/).
## Installation
```{r eval=FALSE}
require(devtools)
install_github("mementohackathon2015/timetravelr")
```
Load `timetravelr`
```{r}
library("timetravelr")
```
## Example
The [Open Archive Initiative](http://www.openarchives.org) is listing [registered OAI conforming repositories](http://www.openarchives.org/Register/BrowseSites) for many years. With the help of web archives and the Memento Time Travel API, it should be possible to assess the evolution of OAI-PMH repositoires.
### Get Timemap index
```{r}
uri <- "http://www.openarchives.org/Register/BrowseSites"
my_oai <- get_timemap(uri)
head(my_oai)
```
The timemap documents `r nrow(my_oai)`mementos.
### Get first Memento
```{r}
my_memo <- get_memento(uri, date_time = my_oai$datetime[1])
tables <- XML::readHTMLTable(my_memo$response)
my_df <- plyr::rbind.fill(tables[5])
head(my_df)
```
In the beginning, OAI initiative listed `r nrow(my_df)` OAI repos (date : `r my_oai$datetime[1]`)
### Get time series
To get a time series, we need to parse all mementos. Let's define a function
```{r}
oai_list <- function(uri = NULL, date_time = NULL) {
my_memo <- get_memento(uri, date_time)
tables <- XML::readHTMLTable(my_memo$response)
out <- plyr::rbind.fill(tables[5])
nrow(out)
}
my_oai <- my_oai[1:10,]
tt <- plyr::ldply(my_oai$datetime, oai_list, uri = "http://www.openarchives.org/Register/BrowseSites")
my_oai$counts <- tt
my_oai
```
## Get Timemap
```{r}
tt <- get_timemap("http://www.base-search.net/about/de/about_sources_date_dn.php?menu=2")
head(tt)
tt <- get_timemap("http://cnn.com")
head(tt)
```
## Redirecting URI to a Memento
```{r}
tt <- get_memento(uri = "http://cnn.com", date_time = "2011-09-11")
summary(tt)
tt$header
```
## Show Mementos for a given uri and date
```{r}
detail_memento("http://cnn.com", "2001-09-11")
```