I have a dataframe similar to the following:
> library(lubridate)
> df <- data.frame(name = c("george", "sara", "sam", "bill"),
start_date = mdy(c("January 1, 2022", "January 2, 2022", "January 5, 2022", "January 6, 2022")),
end_date = mdy(c("January 3, 2022", "January 4, 2022", "January 6, 2022", "January 8, 2022")),
group = c(1,1,2,2))
> df <- df %>%
mutate(date_range = interval(start_date,
end_date))
> df
name start_date end_date group date_range
1 george 2022-01-01 2022-01-03 1 2022-01-01 UTC--2022-01-03 UTC
2 sara 2022-01-02 2022-01-04 1 2022-01-02 UTC--2022-01-04 UTC
3 sam 2022-01-05 2022-01-06 2 2022-01-05 UTC--2022-01-06 UTC
4 bill 2022-01-06 2022-01-08 2 2022-01-06 UTC--2022-01-08 UTC
I would like to create two plots using ggplot if possible:
The first plot I want to display the date range for each person. It's easier to just show you what I mean, see photo.
The second plot I want to average the range for each group and display a boxplot or similar to show the distribution of dates for each group. See photo.
Any thoughts? I'm new to this hence drawing out what I want, I hope that it's helpful and clear.