library(ggplot2) library(scales) library(dplyr) theme_set(theme_gray(base_size=22)) REGRESSION_METHOD <- "loess" SIZE <- 3 df <- read.csv('./unam.csv', header=TRUE) ## Reorder levels df$Region <- factor(df$Region, levels=c("World", "Latin America", "Mexico", "Iberic World", "North America")) df$Ranking <- factor(df$Ranking, levels=c("QS", "SCImago", "CSIC Spain", "URAP", "NTU", "ARWU", "THE")) ## Censoring: ## ## Outlier df <- df[df$Ranking != "THE", ] ## Missing year in many sources df <- df[df$Year != 2024, ] ## Very incomplete , biases regression ## df <- df[! (df$Region == "Latin America" & df$Ranking == "QS"), ] integer_breaks <- function(n) { function(x) pretty_breaks(n)(x) %>% .[. %% 1 == 0] } svg("./Ranking_UNAM_historical.svg", width=16, height=10) ggplot(data=df, mapping=aes(x=Year, y=Rank)) + geom_smooth(method=REGRESSION_METHOD, size=SIZE, color="gray", se=TRUE) + geom_jitter(mapping=aes(x=Year, y=Rank, color=Ranking, shape=Ranking), height=0, width=.1, data=df, size=SIZE, alpha=.5) + geom_line(mapping=aes(x=Year, y=Rank, color=Ranking), data=df) + scale_y_continuous(breaks = integer_breaks(n=6), trans = "reverse") + scale_x_continuous(breaks = integer_breaks(n=6)) + ## theme_minimal() + theme(legend.position = c(.85, .2)) + ggtitle("Academic rankings UNAM 2012-2023") + facet_wrap(~Region, scales = "free_y") dev.off()