Last active
December 21, 2015 17:29
-
-
Save fontanon/6341178 to your computer and use it in GitHub Desktop.
Testing r-openspending package: Income comparision between Universities: Pablo de Olavide vs. Universidad de Granada.
https://github.com/mihi-tr/r-openspending
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("ropenspending") | |
# Retrieving Universidad Pablo de Olavide data at openspending (upo-income-budget dataset) | |
upodata <- openspending.aggregate("upo-income-budget",drilldown=c("articulo")) | |
upodata.df <- openspending.as.data.frame(upodata) | |
# Retrieving Universidad de Granada data at openspending (upo-income-budget dataset) | |
ugrdata <- openspending.aggregate("ugr-income",drilldown=c("articulo")) | |
ugrdata.df <- openspending.as.data.frame(ugrdata) | |
# Coerce values tolower to improve matching | |
upodata.df$articulo.label <- sapply(upodata.df$articulo.label, tolower) | |
ugrdata.df$articulo.label <- sapply(ugrdata.df$articulo.label, tolower) | |
# Merge by "articulo" column | |
articulo.df <- merge(upodata.df, ugrdata.df, by.x="articulo.label", by.y="articulo.label", all=TRUE) | |
articulo.sub <- subset(articulo.df, select = c("articulo.label", "amount.x", "amount.y")) | |
names(articulo.sub) <- c("Articulo", "UPO", "UGR") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment