This repository has been archived by the owner on Sep 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 107
/
Copy pathfulltext.Rmd
170 lines (124 loc) · 6.25 KB
/
fulltext.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
---
title: Full text
author: Scott Chamberlain
date: "2021-02-23"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Full text}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
Search functions in `rplos` can be used to get back full text in addition to
any section of an article. However, if you prefer XML, this vignette is
for you.
### Load package from CRAN
```r
install.packages("rplos")
```
```r
library('rplos')
```
### Get full text URLs
Create urls for full text articles in PLOS journals
Here's the URL for XML full text for the DOI `10.1371/journal.pone.0086169`
```r
full_text_urls(doi = '10.1371/journal.pone.0086169')
```
```
#> [1] "http://journals.plos.org/plosone/article/file?id=10.1371/journal.pone.0086169&type=manuscript"
```
And for the DOI `10.1371/journal.pbio.1001845`
```r
full_text_urls(doi = '10.1371/journal.pbio.1001845')
```
```
#> [1] "http://journals.plos.org/plosbiology/article/file?id=10.1371/journal.pbio.1001845&type=manuscript"
```
The function is vectorized, so you can pass in many DOIs
```r
full_text_urls(doi = c('10.1371/journal.pone.0086169',
'10.1371/journal.pbio.1001845'))
```
```
#> [1] "http://journals.plos.org/plosone/article/file?id=10.1371/journal.pone.0086169&type=manuscript"
#> [2] "http://journals.plos.org/plosbiology/article/file?id=10.1371/journal.pbio.1001845&type=manuscript"
```
Use `searchplos()` to get a lot of DOIs, then get the URLs for full text XML
```r
dois <- searchplos(q = "*:*", fq = 'doc_type:full', limit = 20)$data$id
full_text_urls(dois)
```
```
#> [1] "http://journals.plos.org/ploscompbiol/article/file?id=10.1371/journal.pcbi.0020071&type=manuscript"
#> [2] "http://journals.plos.org/plosbiology/article/file?id=10.1371/journal.pbio.1000152&type=manuscript"
#> [3] "http://journals.plos.org/plosbiology/article/file?id=10.1371/journal.pbio.1000153&type=manuscript"
#> [4] "http://journals.plos.org/plosbiology/article/file?id=10.1371/journal.pbio.1000159&type=manuscript"
#> [5] "http://journals.plos.org/plosbiology/article/file?id=10.1371/journal.pbio.1000165&type=manuscript"
#> [6] "http://journals.plos.org/plosbiology/article/file?id=10.1371/journal.pbio.1000166&type=manuscript"
#> [7] "http://journals.plos.org/plosbiology/article/file?id=10.1371/journal.pbio.1000167&type=manuscript"
#> [8] "http://journals.plos.org/plosbiology/article/file?id=10.1371/journal.pbio.1000173&type=manuscript"
#> [9] "http://journals.plos.org/plosbiology/article/file?id=10.1371/journal.pbio.1000175&type=manuscript"
#> [10] "http://journals.plos.org/plosbiology/article/file?id=10.1371/journal.pbio.1000176&type=manuscript"
#> [11] "http://journals.plos.org/ploscompbiol/article/file?id=10.1371/journal.pcbi.0030121&type=manuscript"
#> [12] "http://journals.plos.org/ploscompbiol/article/file?id=10.1371/journal.pcbi.0030124&type=manuscript"
#> [13] "http://journals.plos.org/ploscompbiol/article/file?id=10.1371/journal.pcbi.0030125&type=manuscript"
#> [14] "http://journals.plos.org/ploscompbiol/article/file?id=10.1371/journal.pcbi.0030127&type=manuscript"
#> [15] "http://journals.plos.org/ploscompbiol/article/file?id=10.1371/journal.pcbi.0030130&type=manuscript"
#> [16] "http://journals.plos.org/plosbiology/article/file?id=10.1371/journal.pbio.1000409&type=manuscript"
#> [17] "http://journals.plos.org/plosbiology/article/file?id=10.1371/journal.pbio.1000410&type=manuscript"
#> [18] "http://journals.plos.org/plosbiology/article/file?id=10.1371/journal.pbio.1000411&type=manuscript"
#> [19] "http://journals.plos.org/plosbiology/article/file?id=10.1371/journal.pbio.1000414&type=manuscript"
#> [20] "http://journals.plos.org/plosbiology/article/file?id=10.1371/journal.pbio.1000421&type=manuscript"
```
### Get XML
Get full text XML of PLOS papers given a DOI
```r
plos_fulltext(doi = '10.1371/journal.pone.0086169')
```
```
#> 1 full-text articles retrieved
#> Min. Length: 110717 - Max. Length: 110717
#> DOIs: 10.1371/journal.pone.0086169 ...
#>
#> NOTE: extract xml strings like output['<doi>']
```
`plos_fulltext()` is vectorized, so you can pass in more than one DOI
```r
plos_fulltext(c('10.1371/journal.pone.0086169','10.1371/journal.pbio.1001845'))
```
```
#> 2 full-text articles retrieved
#> Min. Length: 110717 - Max. Length: 143442
#> DOIs: 10.1371/journal.pone.0086169 10.1371/journal.pbio.1001845 ...
#>
#> NOTE: extract xml strings like output['<doi>']
```
Get many DOIs, then index to get the full XML of the one you want
(output not shown)
```r
dois <- searchplos(q = "*:*", fq = 'doc_type:full', limit = 3)$data$id
out <- plos_fulltext(dois)
xml <- out[dois[1]][[1]]
```
Extract the abstract from the XML
```r
if (requireNamespace("xml2")) {
library("xml2")
xml_text(xml_find_all(read_xml(xml), "//abstract"))
}
```
```
#> [1] "With the burgeoning immunological data in the scientific literature, scientists must increasingly rely on Internet resources to inform and enhance their work. Here we provide a brief overview of the adaptive immune response and summaries of immunoinformatics resources, emphasizing those with Web interfaces. These resources include searchable databases of epitopes and immune-related molecules, and analysis tools for T cell and B cell epitope prediction, vaccine design, and protein structure comparisons. There is an agreeable synergy between the growing collections in immune-related databases and the growing sophistication of analysis software; the databases provide the foundation for developing predictive computational tools, which in turn enable more rapid identification of immune responses to populate the databases. Collectively, these resources contribute to improved understanding of immune responses and escape, and evolution of pathogens under immune pressure. The public health implications are vast, including designing vaccines, understanding autoimmune diseases, and defining the correlates of immune protection."
```
Extract reference lists, just give back first few for brevity
```r
if (requireNamespace("xml2")) {
library("xml2")
xml_find_all(read_xml(out[[3]]), "//ref-list/ref")[1:2]
}
```
```
#> {xml_nodeset (2)}
#> [1] <ref id="pbio.1000153-Fetz1">\n <label>1</label>\n <element-citation pu ...
#> [2] <ref id="pbio.1000153-Wessberg1">\n <label>2</label>\n <element-citatio ...
```