Your Life in Weeks

[This article was first published on R - datawookie, and kindly contributed to R-bloggers]. (You can report issue about the content on 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 on the Founder’s Journal podcast. The episode reviewed an essay, The Opportunity Cost of Everything, by Jack Raines. If you haven’t read it, then I suggest you invest 10 minutes in doing so. It will be time well spent.

Your Life in Weeks

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

The article includes some lovely visualisations like the one copied below.

Retire in your early 60s? Living the dream.

Life Calendar

In the same article Jack Raines mentions the “Life Calendar”, a printed poster breaking down a typical lifespan into weeks. Buy it and decorate as you see fit…

… or you could roll your own.

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

Start off by pulling into two core packages: {dplyr} for data manipulation (strictly I could do everything in base R, but this is more convenient) and {ggplot2} for plotting.

library(dplyr)
library(ggplot2)

I store my birth date in BIRTH. Set up some constants and convert BIRTH to a POSIXlt object. I’m using the same life expectancy as Raines.

ROWS <- 52
# Estimated lifespan in years.
LIFE <- 90

BIRTH <- strptime("16-06-1972", "%d-%m-%Y")

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 <- difftime(Sys.Date(), BIRTH, units = "weeks")
# Convert lifespan to weeks.
LIFE <- LIFE * ROWS

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

life <- factor(
  c(
    rep("past", AGE),
    rep("future", LIFE - AGE + 1)
  ),
  levels = c("past", "future")
)

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

data <- expand.grid(
  y = 1:ROWS,
  x = seq_len((ceiling(length(life) / ROWS)))
) %>%
  mutate(group = life)

And finally use {ggplot2} with geom_tile() to visualise.

Weeks in the past are rendered in red, while the future is grey. I also created a square version.

To leave a comment for the author, please follow the link and comment on their blog: R - datawookie.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)