Working with date and time in R is sometimes tricky. Today I gave lubridate a try and was surprised on how easy it can be. Lubridate is a available on git and on CRAN. There is also a good introduction published in the Journal of Statistical Software.
# Create an object bday <- dmy("23121984")
This could also have been achieved with any combination of d(ay)m(onth)y(ear), i.e. ymd() or dym().
Several options are provided to work with the bday object:
wday(bday) # day of the week wday(bday, label=T) # day of the week, abreviated yday(bday) # day of the year
lubridate also makes it easy to calculate with dates
wday(bday + years(1), label=T) # day of week one year later table(sapply(1:100, function(x) wday(bday + years(x), label=T))) # days of the week for next 100 years.