-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreadme.Rmd
118 lines (89 loc) · 3.43 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
---
output: rmarkdown::github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo=FALSE}
knitr::opts_chunk$set(collapse=TRUE, comment="##", fig.retina=2, fig.path = "README <- figs/README-")
```
`FDAopenR` : R package for accessing and manipulating openFDA API.
<!-- badges: start -->
[![Travis build status](https://app.travis-ci.com/ck2136/FDAopenR.svg?branch=master)](https://travis-ci.com/ck2136/FDAopenR)
[![codecov](https://codecov.io/gh/ck2136/FDAopenR/branch/master/graph/badge.svg?token=PNCASBPWB1)](https://codecov.io/gh/ck2136/FDAopenR)
<!-- badges: end -->
The following functions are implemented:
- ndcToString: Converting numeric ndc values to appropriate ndc string values for open FDA API search
- listSF: Listing Search Field Parameters
- extractFDA: Extracts relevant information from the [open FDA API](https://open.fda.gov/apis/)
### Installation
```{r eval=FALSE}
# you'll want to see the vignettes, trust me
library("devtools")
devtools::install_github("ck2136/FDAopenR")
# for now not on CRAN :(
```
```{r echo=FALSE, message=FALSE, warning=FALSE, error=FALSE}
options(width=120)
```
### Usage
```{r}
library("FDAopenR")
library("dplyr")
# current verison
packageVersion("FDAopenR")
# - - - - - - - - - - - - - - - - - - - - - #
# Instantiate example classes
# - - - - - - - - - - - - - - - - - - - - - #
drug1 <- new(Class="Drug",
ndc = 687889736,
apikey="Y3CgaZj67AotB7b4XLhzHJTY7oBWKUC3u1fYulw8"
)
device1 <- new(Class="Device",
apikey="Y3CgaZj67AotB7b4XLhzHJTY7oBWKUC3u1fYulw8"
)
food1 <- new(Class="Food",
apikey="Y3CgaZj67AotB7b4XLhzHJTY7oBWKUC3u1fYulw8"
)
other1 <- new(Class="Other",
ndc=6382447364,
apikey="Y3CgaZj67AotB7b4XLhzHJTY7oBWKUC3u1fYulw8"
)
```
#### Convert NDC numeric to NDC string
```{r ndcToString, message=FALSE, warning=FALSE, fig.height=9.5, fig.width=9.5}
drug1@ndcquery
drug1 <- ndcToString(drug1)
drug1@ndcquery
#ndcToString(device1) # this will be an error!
other1 <- ndcToString(other1)
other1 %>% str(max.level=2)
```
#### Search Field
```{r searchField, message=FALSE, warning=FALSE, fig.height=9.5, fig.width=9.5}
listSF(drug1,"event") %>% head
listSF(drug1,"label") %>% head
listSF(drug1,"ndc") %>% head
listSF(device1,"510k") %>% head
listSF(device1,"classification") %>% head
listSF(device1,"enforcement") %>% head
listSF(device1,"event") %>% head
listSF(device1,"pma") %>% head
listSF(device1,"recall") %>% head
listSF(device1,"registrationlisting") %>% head
listSF(device1,"udi") %>% head
listSF(food1,"enforcement") %>% head
listSF(food1,"event") %>% head
listSF(other1) %>% head
```
#### Extract FDA information
```{r FDAinfo, message=FALSE, warning=FALSE, fig.height=9.5, fig.width=9.5}
extractFDA(drug1,"event","receivedate:[20040101+TO+20081231]&limit=15")[1:5,1:5]
extractFDA(drug1,"ndc", "finished:true&limit=3")[1:5,1:5]
extractFDA(device1,"registrationlisting",'')[1:5,1:5]
extractFDA(device1,"udi",'public_version_status:Update')[1:5,1:5]
extractFDA(device1,"pma",'decision_code:APPR&limit=3')[1:5,1:5]
extractFDA(food1, "enforcement", 'report_date:[20040101+TO+20131231]&limit=3')[1:5,1:5]
extractFDA(food1, "event", 'date_created:[20040101+TO+20131231]&limit=5')[1:5,1:5]
extractFDA(other1, query='marketing_start_date:[20040101+TO+20131231]&limit=5')[1:5,1:5]
```
## Authors
* [Chong Hoon Kim](mailto:[email protected])