Created
June 2, 2017 13:18
-
-
Save tts/9341c7b326787dc38b5c0751688fae9f to your computer and use it in GitHub Desktop.
Changes from 2016 to 2017 in citations and altmetrics of some Aalto University publications by School
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
# https://blog.dominodatalab.com/visualizing-homeownership-in-the-us-using-small-multiples-and-r/ | |
opts <- theme( | |
panel.background = element_rect(fill="white"), | |
panel.border = element_rect(colour="black", fill=NA), | |
axis.line = element_blank(), | |
axis.ticks = element_blank(), | |
panel.grid.major = element_blank(), | |
panel.grid.minor = element_blank(), | |
axis.text = element_text(colour="gray25", size=15, angle=90, hjust=1), | |
axis.title = element_blank(), | |
text = element_text(size=12), | |
legend.key = element_blank(), | |
legend.position = "none", | |
legend.background = element_blank(), | |
plot.title = element_text(size = 45)) | |
vplayout <- function(x, y) viewport(layout.pos.row = x, layout.pos.col = y) | |
doschool <- function(sc = NULL) { | |
# Arrange data by metrics value | |
s <- data20162017_gathered %>% | |
filter(School == sc) %>% | |
arrange(desc(value)) | |
dois <- unique(s$DOI) | |
if (length(dois) <= 50) { | |
dois <- dois | |
} else { | |
dois <- dois[1:100] | |
} | |
grid.newpage() | |
if ( s[1, "School"] == "ARTS" ) { | |
png(file = paste0("altm_", sc, ".png"), height = 1500, width = 3000) | |
pushViewport(viewport(layout = grid.layout(7, 10, heights = c(.3,.1,rep(1,5)), widths = c(1.1, rep(1,9))))) | |
} else { | |
png(file = paste0("altm_", sc, ".png"), height = 3500, width = 4000) | |
pushViewport(viewport(layout = grid.layout(12, 10, heights=c(.3,.1,rep(1,10)), widths = c(1.1, rep(1,9))))) | |
} | |
grid.text("WoS citations, Mendeley readers, and tweets 2016-2017", | |
gp = gpar(fontsize = 50, col = "gray40"), | |
vp = viewport(layout.pos.row = 1, | |
layout.pos.col = 1:10)) | |
grid.text(paste0("Aalto University, School of ", sc, ". Max 100 items published 2013-2015, sorted by value. Metrics queried 2016-05-13 and 2017-06-01."), | |
gp = gpar(fontsize = 30, col = "gray40"), | |
vp = viewport(layout.pos.row = 2, | |
layout.pos.col = 1:10)) | |
for (i in 1:length(dois)) | |
{ | |
datap <- subset(s, DOI == dois[i]) | |
p <- ggplot(datap, aes(Date, value))+ | |
geom_rect(data = datap, | |
aes(fill = factor(metrics)), | |
xmin = -Inf, xmax = Inf, ymin = -Inf, ymax = Inf, alpha = NA)+ | |
scale_fill_brewer(palette = "Set2")+ | |
geom_line(size = 1.5)+ | |
facet_wrap(DOI ~ metrics)+ | |
{if ( datap[1,"School"] == "ARTS" ) { scale_y_continuous(expand = c(0, 0), limits = c(0,190)) } else { scale_y_log10(limits = c(1,1e3)) }}+ | |
scale_x_date(date_breaks = "1 year", date_labels = "%Y")+ | |
opts | |
if (i%%10! = 1) p <- p+theme(axis.text.y = element_blank()) | |
if (datap[1,"School"] == "ARTS") { | |
if (i <= 40) p <- p+theme(axis.text.x = element_blank()) | |
} else { | |
if (i <= 90) p <- p+theme(axis.text.x = element_blank()) | |
} | |
print(p, vp = vplayout(floor((i-1)/10)+3, i%%10+(i%%10==0)*10)) | |
} | |
dev.off() | |
} | |
doschool("ARTS") | |
doschool("BIZ") | |
doschool("CHEM") | |
doschool("ELEC") | |
doschool("ENG") | |
doschool("SCI") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment