close
close

first Drop

Com TW NOw News 2024

Your life in weeks | R-bloggers
news

Your life in weeks | R-bloggers

(This article was first published on R – datawookieand kindly contributed to R-bloggers). (You can report problems with the content of this page here)


Want to share your content on R-bloggers? Click here if you have a blog, or here if you don’t.

A few months ago, I listened to an episode of the Founder’s Journal podcast. The episode discussed an essay by Jack Raines, The Opportunity Cost of Everything. If you haven’t read it yet, I highly recommend investing 10 minutes in it. It will be time well spent.

Your life in weeks

Jack Raines refers to an article, Your Life in Weeks, by Tim Urban. The article, as you might guess, divides a human life into weeks. Using a week as a quantum of time makes sense: a year is too long, while a second is too short. A week is the Goldilocks time interval, not too long and not too short: it’s just right.

The article contains some nice visualizations, as shown below.

Retiring in your early 60s? Live the dream.

Life Calendar

In the same article, Jack Raines mentions the “Life Calendar,” a printed poster that breaks down a typical lifespan into weeks. Buy it and decorate it however you like…

…or you can roll them yourself.

Of course I prefer the DIY approach. And I’m going to do it in R.

Start by dividing two core packages: {dplyr} for data manipulation (strictly speaking I could do everything in base R, but this is more convenient) and {ggplot2} for making plans.

library(dplyr)
library(ggplot2)

I save my date of birth in BIRTH. Set some constants and convert BIRTH to a POSIXlt object. I use the same life expectancy as Raines.

ROWS 

Next define AGE in weeks and convert LIFE to the same unit.

# Get age by subtracting birth date from current date (and convert to weeks).
AGE 

Create a factor for weeks that are in the past or future.

life 

Now lay it out in a grid. This reminds me of how handy the expand.grid() function is.

data %
  mutate(group = life)

And finally use {ggplot2} of geom_tile() visualize.

Past weeks are shown in red, while future weeks are gray. I also made a square version.