Skip to content

Instantly share code, notes, and snippets.

@dirkschumacher
Last active April 25, 2018 07:41
Show Gist options
  • Save dirkschumacher/b12f7f5fababb6896ec0fc7ce954ee93 to your computer and use it in GitHub Desktop.
Save dirkschumacher/b12f7f5fababb6896ec0fc7ce954ee93 to your computer and use it in GitHub Desktop.
# 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")
@dirkschumacher
Copy link
Author

Uhh nice. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment