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 0
/
README.Rmd
138 lines (102 loc) · 3.63 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
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
rcitoid
=========
[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![cran checks](https://cranchecks.info/badges/worst/rcitoid)](https://cranchecks.info/pkgs/rcitoid)
[![R-check](https://github.com/ropensci/rcitoid/workflows/R-check/badge.svg)](https://github.com/ropensci/rcitoid/actions?query=workflow%3AR-check)
[![codecov](https://codecov.io/gh/ropensci/rcitoid/branch/master/graph/badge.svg)](https://codecov.io/gh/ropensci/rcitoid)
[![rstudio mirror downloads](https://cranlogs.r-pkg.org/badges/rcitoid)](https://github.com/r-hub/cranlogs.app)
[![cran version](https://www.r-pkg.org/badges/version/rcitoid)](https://cran.r-project.org/package=rcitoid)
```{r echo=FALSE}
library("knitr")
hook_output <- knitr::knit_hooks$get("output")
knitr::knit_hooks$set(output = function(x, options) {
lines <- options$output.lines
if (is.null(lines)) {
return(hook_output(x, options)) # pass to default hook
}
x <- unlist(strsplit(x, "\n"))
more <- "..."
if (length(lines)==1) { # first n lines
if (length(x) > lines) {
# truncate the output, but add ....
x <- c(head(x, lines), more)
}
} else {
x <- c(if (abs(lines[1])>1) more else NULL,
x[lines],
if (length(x)>lines[abs(length(lines))]) more else NULL
)
}
# paste these lines together
x <- paste(c(x, ""), collapse = "\n")
hook_output(x, options)
})
knitr::opts_chunk$set(
warning = FALSE,
message = FALSE,
collapse = TRUE,
comment = "#>"
)
```
Client for the Citoid service https://www.mediawiki.org/wiki/Citoid
docs: https://en.wikipedia.org/api/rest_v1/#!/Citation/getCitation
There are two functions, both of which do the same things, except:
- `cit_oid()`: parses text
- `cit_oid_()`: does not parse text, you can parse later yourself
Even with `cit_oid()` though, you get a list of lists, and you may
want to parse it to a data.frame. See an example below.
## Install
Stable version
```{r eval=FALSE}
install.packages("rcitoid")
```
Development version
```{r eval=FALSE}
remotes::install_github("ropensci/rcitoid")
```
Load the package
```{r}
library("rcitoid")
```
## get citation data
use underscore method to get text
```{r}
cit_oid_("10.1108/jd-12-2013-0166")
```
## get citation data
DOI
```{r output.lines=1:10}
cit_oid("10.1108/jd-12-2013-0166")
```
PMID
```{r output.lines=1:10}
cit_oid(30446726)
```
PMCID
```{r output.lines=1:10}
cit_oid("PMC4679344")
```
ISBN
```{r output.lines=1:10}
cit_oid(1439895619)
```
## parse to data.frame
because the resulting data is nested and can have missing data slots,
it's probably easier to get raw text and manipulate from there.
```{r}
library(dplyr)
pmid <- c(30446726, 30722046, 30687373, 30688010)
pmcid <- c("PMC4679344", "PMC6347797", "PMC6347793")
isbn <- 1439895619
dois <- c("10.1109/jsac.2011.110806", "10.1007/s00422-006-0078-4",
"10.5040/9781474219624-0044", "10.1109/icemi.2009.5274826",
"10.1109/wispnet.2017.8299996")
res <- cit_oid_(id = c(pmid, pmcid, isbn, dois))
tbl_df(bind_rows(lapply(res, jsonlite::fromJSON)))
```
## Meta
* Please [report any issues or bugs](https://github.com/ropensci/rcitoid/issues)
* License: MIT
* Get citation information for `rcitoid` in R doing `citation(package = 'rcitoid')`
* Please note that this package is released with a [Contributor Code of Conduct](https://ropensci.org/code-of-conduct/). By contributing to this project, you agree to abide by its terms.
[![ropensci_footer](https://ropensci.org/public_images/github_footer.png)](https://ropensci.org)