How to create a timeline of your CV in R?
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. (It can also be part of your portfolio to show your R skills.)
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.
Note that I wrote this article after reading this original post by Bernardo Lares, and in particular his package, i.e., {lares}
package. A special thanks for his amazing work which was used to create a slightly modified version of the plot_timeline()
function!
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)
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 ###
order <- c("Role", "Place", "Type", "Start", "End")
colnames(cv) <- order
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_minimal() +
theme(panel.background = element_rect(
fill = "white",
colour = NA
), axis.ticks = element_blank(), panel.grid.major.x = element_line(
linewidth = 0.25,
colour = "grey80"
))
if (!is.na(cvlong$type)[1] | length(unique(cvlong$type)) >
1) {
p <- p + geom_line(aes(color = type), linewidth = size) +
facet_grid(type ~ ., scales = "free", space = "free") +
guides(colour = "none") +
scale_colour_manual(values = c("#F8766D", "#00BA38", "#619CFF")) +
theme(strip.text.y = element_text(size = 10))
} else {
p <- p + geom_line(linewidth = size)
}
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)
}
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 usingtoday
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.
Additional note
Instead of editing the code according to your roles directly in the script, you can also create an Excel file with the required data (job title, workplace, type, start date, end date) and then import it into R. Editing the Excel file is easier and less prone to coding errors. Moreover, if you have a long career, the code may become long while if you import the Excel file, it will always stay short and concise.
Conclusion
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.
As always, if you have a question or a suggestion related to the topic covered in this article, please add it as a comment so other readers can benefit from the discussion.
A special thanks to Prof. Job N Nmadu for the suggestion about creating the file that holds the data.
Liked this post?
- Get updates every time a new article is published (no spam and unsubscribe anytime):