Assume we have a timetable over 2 years. Each year, we want to do something at certain days, and mark these days on the timeline. Similar to a Gant char, but the difference is that periods can have gaps in between. This means for instance there is an activity from 13. to 20. April, and the next one from 1. to 8. May of the same year. In the MWE below I am only using a time period from 1. January 2000 to 28. February 2000, for simplicity:
library(data.table)
library(ggplot2)
x <- seq(as.Date("2000/01/01"),
as.Date("2000/02/28"), "day")
y <- x
y[c(3,6,8,9,34:43,50:59)] <- NA
x[c(1,2,3,12:33,44:58)] <- NA
timetable <- data.table(Year=c(rep("Year_1",59),rep("Year_2",59)),
date=c(x,y))
How can I create a timetable which illustrates the activities in form of rectangular shapes? Similar to the charts shown here: Gantt charts with R or here: Creating a Multi-Project Timeline Using ggplot2 in R But here it should allow gaps in between.
So in other words, what I am trying to do is to fill out an existing timeline, and leave out days with no activities (blank). How can this be done with ggplot2
?