grant_id <- 1:100
funding_agency <- sample(rep(c("NIAID", "NIGMS", "NHLBI", "NCI", "NINDS"), 20))
study_section <- sample(rep(
c("Tumor Cell Biology", "Tumor Progression", "Vector Biology",
"Molecular Genetics", "Medical Imaging", "Macromolecular Structure",
"Infectious Diseases", "Drug Discovery",
"Cognitive Neuroscience", "Aging and Geriatrics"), 10
))
total_cost <- rnorm(100, mean = 30000, sd = 10000)
# source, target and value have to be the names
d <- data.frame(
id = grant_id,
source = funding_agency,
target = study_section,
value = total_cost
)
require(rCharts)
sankeyPlot <- rCharts$new()
sankeyPlot$setLib('https://timelyportfolio.github.io/rCharts_d3_sankey')
sankeyPlot$set(
data = d,
nodeWidth = 15,
nodePadding = 10,
layout = 32,
width = 750,
height = 500,
labelFormat = ".1%"
)
sankeyPlot