Births again

Since I had previously played with NZ birth data, so had a bunch of code lying around


and Scientific America published some visualisations


I thought I would match the time of year visualisation with the New Zealand data

Because New Zealand has opposite seasons, but a seasonality that is more similar to the US than different, I am not sure anything generalisable should be read into statements about temperature and the US data that were made- in NZ it is opposite in terms of warmth and conception, so I think a broader explanation of distance from the New Year makes a lot more sense in both cases.


download.file("http://www.stats.govt.nz/~/media/Statistics/browse-categories/population/pop-birthdays-table/most-common-birthdays-19802014.xlsx", destfile="b.xlsx", mode="wb")
bnums <- read_excel("b.xlsx", sheet = 2, skip=2)

names(bnums)[1] <- "day"

longform <- bnums %>% gather(key=month, value=births, January:December) %>% 
 filter(!is.na(births) & !(month=="February" & day==29)) %>%
 mutate(day_of_year = 1:n(), perc = births/mean(births),
 radial_day= 360 -360*day_of_year/365,
 next_radial_day= lead(radial_day))

longform$next_radial_day[365] <- longform$radial_day[1]

polar.plot(1, polar.pos=longform$radial_day, 
 radial.lim=c(0.5,1.5), start=90,
 labels = "", main=NULL,lwd=0.5, rp.type="p",
 show.grid.labels=FALSE, show.grid=FALSE, mar=c(0,0,0,0))
lines(c(0,0),c(0,0.7), col="#AAAAAA")
polar.plot(longform$perc, polar.pos=longform$radial_day, add=TRUE, 
 radial.lim=c(0.5,1.5), start=90,
 line.col="red", lwd=0.5, rp.type="p", poly.col="red")
polar.plot(1, polar.pos=longform$radial_day, add=TRUE, 
 radial.lim=c(0.5,1.5), start=90,
 line.col="blue", lwd=0.5, rp.type="p", poly.col="blue")
longform$perc[longform$perc > 1] <- 1
polar.plot(longform$perc, polar.pos=longform$radial_day, add=TRUE, 
 radial.lim=c(0.5,1.5), start=90,
 line.col="white", lwd=0.5, rp.type="p", poly.col="white")
polar.plot(1.1, polar.pos=longform$radial_day, add=TRUE, 
 radial.lim=c(0.5,1.5), start=90,
 line.col="#AA0000", lwd=0.5, rp.type="p", poly.col=NA)
polar.plot(0.9, polar.pos=longform$radial_day, add=TRUE, 
 radial.lim=c(0.5,1.5), start=90,
 line.col="#0000AA", lwd=0.5, rp.type="p", poly.col=NA)
text(0,0.7,label="January", col="#AAAAAA", cex=0.8, pos=4)
text(0,0.7,label="December", col="#AAAAAA", cex=0.8, pos=2)
lines(c(-.8,-.8),c(-.8,-0.7), col="#AA0000")
text(-.8, -0.75,label="+10% above average", col="#AA0000", cex=0.8, pos=4)
lines(c(.2,.2),c(-.8,-0.7), col="#0000AA")
text(.2, -0.75,label="-10% below average", col="#0000AA", cex=0.8, pos=4)



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s