lubridate

lubridate characters to dates

Art by Allison Horst @allison_horst So far I have learned that lubridate has some nice functions for pulling date components like day, month, or year and using them within group_by() and summarise() or ggplot(). But most of the time when I am working with date data in the real world, R doesn’t even think my dates are dates. Most of the time date data that I read into R gets parsed as characters.

lubridate month() + wday()

Art by Allison Horst @allison_horst When I am trying to work out a problem with R, I generally skip the package documentation, I avoid stack overflow, and I go straight for a blog post written by someone who has just learned what I am trying to learn. I think when you have just learned something, you are in THE BEST PLACE to teach someone else. You are acutely aware of what it feels like to not “get it”.

lubridate first google

I have set myself a challenge of learning to deal with dates in R. Nothing like setting a date for an R-Ladies Sydney event where you will teach other people to spur the motivation for learning how to use the lubridate package. The plan is to learn how to use the package and document my learning process along the way so that at the end of Oct I can tell everyone…

calculating age

I have been playing with a new (not actually new, but new to R) dataset this week. Successes: I loaded the data in using read_csv. I made dates into dates. The interview group is listed as 1s and 2s in the file so R thought those were integers. So I used as.factor to convert. dataframe$variable <- as.factor(dataframe$variable) I used lubridate package to specify that DOB and Test_date were dates with Day Month Year (dmy) format.