Removed data files
[covid19.git] / euromomo / Output_cumulated_v42.R
diff --git a/euromomo/Output_cumulated_v42.R b/euromomo/Output_cumulated_v42.R
deleted file mode 100644 (file)
index 48f3e71..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-### Graphs - cumulated ###\r
-\r
-results4 <- read.table(\r
-      paste0(outdir, "/", country, "_output_v4", ifelse(IArest, "_IArestricted", ""), ".txt"), \r
-      header = TRUE, sep =";", dec=".")\r
-note <- ifelse(IArest, "Note: Negative effects of IA are not shown", "")\r
-results4$agegrp.labels <- factor(results4$agegrp, \r
-    labels = c("0-4 years", "5-14 years", "15-64 years", "Aged 65", "Total"))\r
-\r
-\r
-pal <- c("#E41A1C", "#377EB8", "#4DAF4A", "#984EA3", "#FF7F00", "#A65628", "#F781BF")\r
-\r
-plotCumulSingle <- function(a, mortality=FALSE, lwd=2, ylab=NULL) {\r
-  if (mortality) {\r
-    yvar <- "cm"\r
-    ylb <- "Deaths / 100,000"\r
-    title <- paste0("Cumulated ",s," mortality attributable to ",t,", age group: ",unique(results4$agegrp.labels)[a+1])\r
-  } else {\r
-    yvar <- "cd"\r
-    ylb <- "Number of deaths"\r
-    title <- paste0("Cumulated ",s," number of deaths attributable to ",t,", age group: ",unique(results4$agegrp.labels)[a+1])\r
-  }\r
-  if (!is.null(ylab)) ylb <- ylab\r
-  xlb <- "Week number"\r
-  if (is.na(ylb)) xlb <- NA\r
-  \r
-  with(out[(out$agegrp==a),], {\r
-    plot(x=wk, y=get(yvar), type="n", xaxt="n", bty="l", \r
-      xlab=xlb, ylab=ylb,\r
-      col=pal[1:length(levels(season))][as.integer(season)]\r
-    )\r
-    if (!is.na(ylb)) {\r
-      mtext(title, side=3, line=2, adj=0)\r
-      mtext(sprintf("FluMOMO v4 - week %s, %s", end_week, end_year), side=3, line=2, adj=1, cex=0.8)\r
-    }\r
-    axis(1, at=seq(1, max(wk), 4), labels = unique(floor(week))[seq(1, max(wk), 4)])\r
-    grid(nx=NA, ny=NULL)\r
-    abline(v=seq(1, max(wk), 4), col="lightgray", lty="dotted")\r
-    mapply(function(s, col, l) {\r
-      points(x=wk[season==s], y=get(yvar)[season==s], col=col, type="l", lty=l, lwd=lwd)\r
-    }, s=levels(season), col=rev(pal[1:length(levels(season))]), \r
-    l=c(rep("dotted", length(levels(season))-1), "solid"))\r
-  })\r
-}\r
-\r
-\r
-plotCumulMultiple <- function(mortality=FALSE, lwd=2, ylab=NULL) {\r
-  par(mfrow=c(5,1), oma=c(6,3,2,0))\r
-  for (a in 0:4) {\r
-    par(mar=c(3,2,3,2))\r
-    plotCumulSingle(a, mortality, ylab=NA)\r
-    legend("topleft", levels(results4$agegrp.labels)[a+1], bty="n", xpd=NA, cex=1.3, inset=c(0,-0.2))\r
-  }\r
-  mtext(paste0("Cumulated ",s, ifelse(mortality, " mortality", " number of deaths"), " attributable to ",t,", age group: ",unique(results4$agegrp.labels)[a+1]), side=3, line=0, adj=0, outer=TRUE)\r
-  mtext(sprintf("FluMOMO v4 - week %s, %s", end_week, end_year), side=3, line=0, adj=0.95, cex=0.8, outer=TRUE)\r
-  mtext(ifelse(mortality, "Deaths / 100,000", "Number of deaths"), side=2, line=1, outer=TRUE)\r
-  mtext("Week number", side=1, line=3, cex=0.8)\r
-  legend("bottom", legend=rev(levels(out$season)),\r
-    lty = c("solid", rep("dotted", length(levels(out$season))-1)),\r
-    col = pal[1:length(levels(out$season))], lwd=2, cex=1.2,\r
-    bty="n", horiz=TRUE, xpd=NA, inset=c(0,-0.59))\r
-}\r
-\r
-\r
-for (s in c("summer","winter","year")) {\r
-  for (t in c("IA")) {\r
-    out <- results4[!is.na(results4[,s]), \r
-        c("agegrp","agegrp.labels","year","week",paste0("cEd",t,"_",s),"N")]\r
-    colnames(out) <- c("agegrp","agegrp.labels","year","week","cd","N")\r
-    out$cm <- 100000 * out$cd / out$N\r
-    out[out$week==53,"week"] <- 52.5\r
-    if (s == "winter") {\r
-      out$wk <- with(out, 1 + (week-40)*(week>=40) + (week+12)*(week<=20))\r
-      out$season <- factor(paste0(as.character(with(out, year*(week>=40) + (year-1)*(week<=20))),"/",substr(as.character(with(out, year*(week>=40) + (year-1)*(week<=20))+1),3,4)))\r
-    }\r
-    if (s == "summer") {\r
-      out$wk <- out$week-20\r
-      out$season <- factor(out$year)\r
-    }\r
-    if (s == "year") {\r
-      out$wk <- out$week\r
-      out$season <- factor(out$year)\r
-    }\r
-    out <- out[with(out, order(agegrp, wk)),]\r
-    png(paste0(outdir,"/cumulated_",t,"_deaths_agegroups_",s,"_v4", ifelse(IArest, "_IArestricted", ""), ".png"), width=1200, height=1600, res=130)\r
-    plotCumulMultiple()\r
-    dev.off()\r
-    if (population) {\r
-      png(paste0(outdir,"/cumulated_",t,"_mr_agegroups_",s,"_v4", ifelse(IArest, "_IArestricted", ""), ".png"), width=1200, height=1600, res=130)\r
-      plotCumulMultiple(mortality=TRUE)\r
-      dev.off()\r
-    }\r
-    for (a in 0:4) {\r
-      png(paste0(outdir,"/cumulated_",t,"_deaths_agegroup_",a,"_",s,"_v4", ifelse(IArest, "_IArestricted", ""), ".png"), width=1200, height=800, res=130)\r
-      par(oma=c(3,0,0,0))\r
-      plotCumulSingle(a)\r
-      legend("bottom", legend=rev(levels(out$season)),\r
-        lty = c("solid", rep("dotted", length(levels(out$season))-1)),\r
-        col = pal[1:length(levels(out$season))], lwd=2,\r
-        bty="n", horiz=TRUE, xpd=NA, inset=c(0,-0.35))\r
-      dev.off()\r
-      if (population) {\r
-        png(paste0(outdir,"/cumulated_",t,"_mr_agegroup_",a,"_",s,"_v4", ifelse(IArest, "_IArestricted", ""), ".png"), width=1200, height=800, res=130)\r
-        par(oma=c(3,0,0,0))\r
-        plotCumulSingle(a, mortality=TRUE)\r
-        legend("bottom", legend=rev(levels(out$season)),\r
-          lty = c("solid", rep("dotted", length(levels(out$season))-1)),\r
-          col = pal[1:length(levels(out$season))], lwd=2,\r
-          bty="n", horiz=TRUE, xpd=NA, inset=c(0,-0.35))\r
-        dev.off()\r
-      }\r
-    }\r
-  }\r
-}\r
-rm(plotCumulSingle, plotCumulMultiple, results4, a, s, t, out, note, pal)\r