Skip to content

Instantly share code, notes, and snippets.

@stevepowell99
Created November 13, 2019 12:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevepowell99/8c5d59d3d1af13a3c1693f2358314e25 to your computer and use it in GitHub Desktop.
Save stevepowell99/8c5d59d3d1af13a3c1693f2358314e25 to your computer and use it in GitHub Desktop.
heatmaps for UNICEF ECARO
library(tidyverse)
library(readxl)
suppressMessages(library(dendextend))
library(d3heatmap)
data <- readxl::read_excel("Data.xlsx",range="A3:CU24",na="NK")
mat=data %>% select(-(1:3))
rownames(mat) <- data[1:21,1]
mat2 <- mat %>%
select_if(~sum(!is.na(.)) > 0)
vec <- unclass(data[1:21,1]) %>% as.vector %>% `[[`(1)
d3heatmap(mat2,labRow = vec,xaxis_height = 200)
policy <- mat2 %>% select(contains("Policy Design"))
policy %>%
d3heatmap(labRow = vec,xaxis_height = 200)
financing <- mat2 %>% select(contains("Financing"))
financing %>%
d3heatmap(labRow = vec,xaxis_height = 200)
coordination <- mat2 %>% select(contains("Coordination"))
coordination %>%
d3heatmap(labRow = vec,xaxis_height = 200)
implementation <- mat2 %>% select(contains("Implementation"))
implementation %>%
d3heatmap(labRow = vec,xaxis_height = 400,yaxis_width = 200)
combined <- (policy+financing+coordination+implementation)
colnames(combined) <- str_remove(colnames(combined)," - Policy Design")
combined %>%
d3heatmap(labRow = vec,xaxis_height = 400,yaxis_width = 200)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment