#TIL 13ths are more often Fridays: library(data.table) data.table(d=seq(Sys.Date()-365.25*400, Sys.Date()+365.25*400, by=1))[ mday(d)==13,.(weekday=wday(d))][ ,.(count=.N),by=weekday][ order(weekday)] #rstats /cc @df7cb @josepheconway

Dec 13, 2019 · 12:29 PM UTC

4
6
28
That is in response / as a follow-up to @df7cb showing the same in #postgresql but I couldn't reply-tweet with a screenshot ... Also no space for the #rdatatable tag the tweet really needed too.
#TIL 13ths are more often Fridays than other weekdays: select extract(dow from d), count(*) from generate_series(date 'today' - interval '400 years', date 'today' + interval '400 years', interval '1 day') as g(d) where extract(day from d) = 13 group by 1 order by 1; @PostgreSQL
1
1
The correct frequencies, for any 400-year period, are (Sun .. Sat): 687, 685, 685, 687, 684, 688, 684 You could have noticed Christoph's error by the fact that the results added up to an odd number.
1
data.table(d=seq(Sys.Date()-365.25*400, Sys.Date()+365.25*400, by=1))[mday(d)==13, .(count = .N), keyby = .(weekday=wday(d))]
2