The goal of fedreporter
is to provide downloads data from NIH 'ExPORTER'
You can install fedreporter
from GitHub with:
# install.packages("remotes")
remotes::install_github("muschellij2/fedreporter")
library(fedreporter)
res = fe_projects_search(
project_number = "*R01*",
fiscal_year = 2012,
agency = "NIH",
text = "stroke",
text_field = "title")
#> GET command is:
#> Response [https://api.federalreporter.nih.gov/v1/Projects/search?query=projectNumber%3A*R01*%24fy%3A2012%24agency%3ANIH%24text%3Astroke%24textFields%3Atitle%24textOperator%3AAND&offset=1&limit=50]
#> Date: 2017-10-03 15:33
#> Status: 200
#> Content-Type: application/json; charset=utf-8
#> Size: 249 kB
names(res)
#> [1] "response" "content"
res$response
#> Response [https://api.federalreporter.nih.gov/v1/Projects/search?query=projectNumber%3A*R01*%24fy%3A2012%24agency%3ANIH%24text%3Astroke%24textFields%3Atitle%24textOperator%3AAND&offset=1&limit=50]
#> Date: 2017-10-03 15:33
#> Status: 200
#> Content-Type: application/json; charset=utf-8
#> Size: 249 kB
length(res$content)
#> [1] 4
names(res$content)
#> [1] "totalCount" "offset" "limit" "items"
res$content$offset
#> [1] 1
length(res$content$items)
#> [1] 50
res = fe_projects_search(pi_name = "MATSUI, ELIZABETH")
#> GET command is:
#> Response [https://api.federalreporter.nih.gov/v1/Projects/search?query=piName%3AMATSUI%2C%20ELIZABETH&offset=1&limit=50]
#> Date: 2017-10-03 15:33
#> Status: 200
#> Content-Type: application/json; charset=utf-8
#> Size: 128 kB
items = res$content$items
con_pis = sapply(items, "[[", "contactPi")
keep = grepl("^MATSUI", con_pis)
items = items[keep]
mat_costs = sapply(items, "[[", "totalCostAmount")
sum(mat_costs)
#> [1] 16021336
res = fe_projects_search(pi_name = "PENG, ROGER")
#> GET command is:
#> Response [https://api.federalreporter.nih.gov/v1/Projects/search?query=piName%3APENG%2C%20ROGER&offset=1&limit=50]
#> Date: 2017-10-03 15:33
#> Status: 200
#> Content-Type: application/json; charset=utf-8
#> Size: 55 kB
items = res$content$items
con_pis = sapply(items, "[[", "contactPi")
keep = grepl("^PENG", con_pis)
items = items[keep]
peng_costs = sapply(items, "[[", "totalCostAmount")
sum(peng_costs)
#> [1] 2868853
# both = fe_projects_search(pi_name = c("MATSUI, ELIZABETH", "PENG, ROGER"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.