How to create a timeline of your CV in R

January 25, 2020
By

[This article was first published on R on Stats and R, 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.

Introduction

In this article, I show how to create a timeline of your CV in R. A CV timeline illustrates key information about your education, work experiences and extra activities. The main advantage of CV timelines compared to regular CV is that they make you stand out immediately by being visually appealing and easier to scan. It also allows you to better present your “story” by showing the chronology of your jobs and activities and thus explain how you got to where you are today.

We show below how to create such CV in R with a minimal reproducible example. Feel free to use the code and adapt it to you. For a more complete example (together with the code) you can check my own CV timeline here.

Minimal reproducible example

Here is the code and the result of a minimal reproducible example:

# All packages used below must be installed first
library(devtools)
# devtools::install_github("laresbernardo/lares")
library(lares)
library(ggplot2)

plot_timeline2 <- function(event, start, end = start + 1, label = NA, group = NA,
                           title = "Curriculum Vitae Timeline", subtitle = "Antoine Soetewey",
                           size = 7, colour = "orange", save = FALSE, subdir = NA) {
  df <- data.frame(
    Role = as.character(event), Place = as.character(label),
    Start = lubridate::date(start), End = lubridate::date(end),
    Type = group
  )
  cvlong <- data.frame(pos = rep(
    as.numeric(rownames(df)),
    2
  ), name = rep(as.character(df$Role), 2), type = rep(factor(df$Type,
    ordered = TRUE
  ), 2), where = rep(
    as.character(df$Place),
    2
  ), value = c(df$Start, df$End), label_pos = rep(df$Start +
    floor((df$End - df$Start) / 2), 2))
  maxdate <- max(df$End)
  p <- ggplot(cvlong, aes(
    x = value, y = reorder(name, -pos),
    label = where, group = pos
  )) + geom_vline(
    xintercept = maxdate,
    alpha = 0.8, linetype = "dotted"
  ) + labs(
    title = title,
    subtitle = subtitle, x = NULL, y = NULL, colour = NULL
  ) +
    theme_lares2() + theme(panel.background = element_rect(
      fill = "white",
      colour = NA
    ), axis.ticks = element_blank(), panel.grid.major.x = element_line(
      size = 0.25,
      colour = "grey80"
    ))
  if (!is.na(cvlong$type)[1] | length(unique(cvlong$type)) >
    1) {
    p <- p + geom_line(aes(color = type), size = size) +
      facet_grid(type ~ ., scales = "free", space = "free") +
      guides(colour = FALSE) +
      scale_colour_hue()
  }
  else {
    p <- p + geom_line(size = size, colour = colour)
  }
  p <- p + geom_label(aes(x = label_pos),
    colour = "black",
    size = 2, alpha = 0.7
  )
  if (save) {
    file_name <- "cv_timeline.png"
    if (!is.na(subdir)) {
      dir.create(file.path(getwd(), subdir), recursive = T)
      file_name <- paste(subdir, file_name, sep = "/")
    }
    p <- p + ggsave(file_name, width = 8, height = 6)
    message(paste("Saved plot as", file_name))
  }
  return(p)
}

order <- c("Role", "Place", "Type", "Start", "End")
today <- as.character(Sys.Date())


### Edit from here ###
cv <- data.frame(rbind(
  c("PhD in Statistics", "University3", "Academic", "2017-09-01", today),
  c("MSc in Econometrics", "University2", "Academic", "2015-09-01", "2017-08-31"),
  c("BSc in Economics", "University1", "Academic", "2010-09-01", "2013-08-31"),
  c("Job title2", "Company2", "Work Experience", "2016-09-01", today),
  c("Job title1", "Company1", "Work Experience", "2013-08-31", "2015-08-31"),
  c("Extra1", "Place1", "Extra", "2015-05-01", today),
  c("Extra2", "Place2", "Extra", "2019-01-01", today),
  c("Extra3", NA, "Extra", "2019-12-01", today)
))
### Edit until here ###


colnames(cv) <- order
colour <- c("red", "blue", "green")

plot_timeline2(
  event = cv$Role,
  start = cv$Start,
  end = cv$End,
  label = cv$Place,
  group = cv$Type,
  save = FALSE,
  subtitle = "Antoine Soetewey" # replace with your name
)

How to personalize it

If you want to edit the example with your own academic, extra and work experiences you basically just have to edit the dataframe called cv in the code above. Each row of the dataset cv is a different academic program, job or activity. Rows should include:

  • the name of the academic program, job title or activity
  • the name of the university, school, company or workplace
  • the category: academic, work experience or extra
  • the starting date (dates must be in format yyyy-mm-dd)
  • the ending date. If the role has not yet ended, type today instead of the date. By using today your CV timeline will automatically adapt to today’s date

Add or remove a row in the dataframe if you want to add or remove a role. Indicate NA if you do not want to specify any workplace (as it has been done for Extra3). Last, do not forget to replace my name with yours for the subtitle of the timeline at the end of the code.

Experienced R users may wish to edit the plot_timeline2 function to their needs. However, if you are happy with the template and design of the example, you only have to change things mentioned above.

Thanks for reading. I hope this article helped you to create a timeline of your CV in R. If you would like to see a more complete and live example, see my timeline CV. See other articles related to R here. As always, if you find a mistake/bug or if you have any questions do not hesitate to let me know in the comment section below, raise an issue on GitHub or contact me. Get updates every time a new article is published by subscribing to this blog.

A special thanks to Bernardo Lares for providing the first version of the code.

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

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.



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers

Sponsors

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)