Created
August 2, 2018 10:58
-
-
Save jayhesselberth/6aed2c2e8f54c67bc046c8861443992d to your computer and use it in GitHub Desktop.
Academic-industry NIH funding by state
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(nihexporter) | |
library(tidyverse) | |
library(rlang) | |
library(cowplot) | |
grant_funds <- function(codes, code_name) { | |
code_name <- rlang::sym(code_name) | |
projects %>% | |
filter(activity %in% codes) %>% | |
select(application.id, activity, fy.cost, fiscal.year) %>% | |
left_join(project_orgs, by = "application.id") %>% | |
left_join(org_info, by = "org.duns") %>% | |
select(activity, fy.cost, fiscal.year, org.state) %>% | |
mutate( | |
activity = fct_collapse( | |
activity, !!code_name := codes | |
) | |
) %>% | |
na.omit() %>% | |
# filter for US states | |
filter(org.state %in% state.abb) | |
} | |
fund_summary <- function(funds) { | |
group_by(funds, activity, fiscal.year, org.state) %>% | |
summarize(total.cost = sum(fy.cost, na.rm = TRUE)) %>% | |
ungroup() | |
} | |
academic_funds <- grant_funds(c('R01'), "academic") %>% fund_summary() | |
industry_funds <- grant_funds(c('R41','R42'), "industry") %>% fund_summary() | |
combined_funds <- bind_rows(academic_funds, industry_funds) %>% | |
spread(activity, total.cost) %>% na.omit() %>% | |
mutate(fund.ratio = log10(academic / industry)) | |
ggplot(combined_funds, aes(fiscal.year, fund.ratio)) + | |
geom_point() + geom_line() + | |
facet_wrap(~ org.state) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Created on 2018-08-02 by the reprex package (v0.2.0).