Last active
April 25, 2018 07:41
-
-
Save dirkschumacher/b12f7f5fababb6896ec0fc7ce954ee93 to your computer and use it in GitHub Desktop.
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
# this is just a script to test the rhxl package, I just quickly looked at the data | |
# Ethiopia Who is doing What Where - 3W December 2017 | |
# source: https://data.humdata.org/dataset/3w-december-2017 | |
url <- "https://data.humdata.org/dataset/615416d2-457b-461a-8155-090f0ced0bf8/resource/f71bf111-8706-42f4-ba46-4ce3c8c949dc/download/3w_hxl.xlsx" | |
# load the rhxl package | |
# https://github.com/dirkschumacher/rhxl | |
library(rhxl) | |
download.file(url, "file.xlsx") | |
data <- as_hxl(readxl::read_xlsx("file.xlsx")) | |
# get the schema | |
hxl_schema(data) | |
# plot ongoing activities | |
library(ggplot2) | |
library(dplyr) | |
plot_data <- hxl_select(data, c("#org+impl", "#status", "#adm1+name")) | |
# set predictable column names | |
colnames(plot_data) <- c("org", "status", "admin1") | |
plot_data <- plot_data %>% | |
group_by(admin1, status) %>% | |
summarise(count_org = n()) | |
ggplot(plot_data) + | |
aes(x = status, y = count_org) + | |
geom_bar(stat = "identity") + | |
facet_wrap(~admin1) + | |
theme(axis.text.x = element_text(angle = 90)) + | |
ggtitle("Project overview by admin1 - Ethiopia Who is doing What Where - 3W December 2017 ") + | |
ylab("#Projects") + xlab("Project status") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That's really awesome and we can plug in into the new
rhdx
R package (work in progress).