Dashboard: norovirus

April 14, 2026 (I)

There were some concerns about the axis labeling with respect to time. This turns out to be relatively complicated, but interesting. For those of you that wanted data-wrangling, this is a very good problem. As it turned out, one “fix” introduced more, and perhaps even more confusing, complications. This is left unfinished to offer a challenge.

dat <- read.delim("./data/noro.csv", header = TRUE, sep = "\t")
dat2 <- dat[ , c("Week", "Yrs_2020_21")]
head(dat2)
    Week Yrs_2020_21
1  1-Aug           0
2  8-Aug           1
3 15-Aug           1
4 22-Aug           2
5 29-Aug           1
6  5-Sep           0
dat2$Date <- paste(dat2$Week, c(rep(2020, 22), rep(2021, 30)), sep = "-")
dat2$Date <- as.Date(dat2$Date, "%d-%b-%Y")
names(dat2)[2] <- "Outbreaks"
dat2$Month <- substr(dat2$Date, 6, 7)
head(dat2)
    Week Outbreaks       Date Month
1  1-Aug         0 2020-08-01    08
2  8-Aug         1 2020-08-08    08
3 15-Aug         1 2020-08-15    08
4 22-Aug         2 2020-08-22    08
5 29-Aug         1 2020-08-29    08
6  5-Sep         0 2020-09-05    09

This graph, while well-intentioned is deceptive. Our data starts on August 1, 2020 (i.e., “month 8”) and ends on July 20-something, 2021 (i.e., “month 1”). These months are presented deceptively (“1” corresponds to year 2021, but the “8” is from year 2020).

agg <- aggregate(dat2$Outbreaks, by = list(dat2$Month), sum)
agg
   Group.1   x
1       01  35
2       02  53
3       03 108
4       04 155
5       05  88
6       06  37
7       07  28
8       08   5
9       09   2
10      10   3
11      11   4
12      12   3
names(agg) <- c("Month", "Outbreak.Total")
agg
   Month Outbreak.Total
1     01             35
2     02             53
3     03            108
4     04            155
5     05             88
6     06             37
7     07             28
8     08              5
9     09              2
10    10              3
11    11              4
12    12              3
plot(Outbreak.Total ~ Month, agg)

Plotting a subset of months offers some clues.

```{r}
#| eval: false
plot(Outbreak.Total ~ Month, agg, subset = Month > 7)
```

Again using subseting is a good idea, but still not quite right.

agg$Month <- as.numeric(agg$Month)
plot(Outbreak.Total ~ I(Month - 7), agg, subset = Month > 7, xlim = c(0, 12), ylim = range(agg$Outbreak.Total))
points(Outbreak.Total ~ I(Month+7), agg, subset = Month <= 7)

Aggregating by month name is perhaps more problematic as time is ordered alphabetically.

dat2$Month2 <- months(dat2$Date)
agg2 <- aggregate(dat2$Outbreaks, by = list(dat2$Month2), sum)
agg2
     Group.1   x
1      April 155
2     August   5
3   December   3
4   February  53
5    January  35
6       July  28
7       June  37
8      March 108
9        May  88
10  November   4
11   October   3
12 September   2

I would probably compute a “fake” time variable that corresponds to months within this weird variant of August - July year.