Created
April 30, 2022 19:50
-
-
Save thlytras/a3c4f606c54c9e200e36ce379b4fb306 to your computer and use it in GitHub Desktop.
Show that EuroMOMO average z-scores are not zero
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
# Data from: https://www.euromomo.eu/graphs-and-maps/#z-scores-by-country | |
dat <- read.csv2("charts-z-scores-by-country.csv") | |
dat$y <- as.integer(substr(dat$week, 1,4)) | |
dat$zscore <- as.numeric(dat$zscore) | |
a <- aggregate(dat[,"zscore",drop=F], dat[,c("country","y")], mean, na.rm=TRUE) | |
b <- aggregate(dat[,"zscore",drop=F], dat[,"country",drop=F], mean, na.rm=TRUE) | |
b <- b[nrow(b):1,] | |
a$x <- match(a$country, b$country) | |
par(mar=c(5,10,3,2), family="Fira Sans") | |
plot(b$zscore, 1:nrow(b), pch=15, cex=1.5, xlim=range(a$zscore), yaxt="n", bty="l", ylab=NA, xlab="Mean z-score", col="purple3") | |
axis(2, at=1:nrow(b), labels=b$country, las=1) | |
points(a$zscore, a$x, cex=0.4, col="grey50") | |
legend("top", c("Annual mean, 2017-2021", "Overall mean, 2017-2021"), pch=c(15,21), pt.cex=c(1,0.4), col=c("purple3","grey50"), bty="n", inset=c(0,-0.08), xpd=NA, horiz=TRUE) | |
mtext("Source: EuroMOMO network", side=1, adj=-0.4, line=2.9, cex=0.9) | |
savePlot("charts-z-scores.png") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment