-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLabGantt.R
68 lines (56 loc) · 2.39 KB
/
LabGantt.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#! Based on https://www.r-bloggers.com/2020/03/using-r-simple-gantt-chart-with-ggplot2/
#! Inspiation Janet Hill https://research-groups.usask.ca/hilllab/index.php
library(tidyverse)
library(lubridate)
library(here)
# read in people information
LabGantt <- read_csv(here("LabGantt.csv"))
CommitteeGantt <- read_csv(here("CommitteeGantt.csv"))
# When no end date, change to today's date
LabGantt$End[is.na(LabGantt$End)] <- Sys.Date()
# Calculate total number of days spent in lab
LabGantt$Days <- LabGantt$End - LabGantt$Start
# Arrange based on start date, followed by total number of days
LabGantt <- arrange(LabGantt, Start, desc(Days))
LabGantt$Name <- factor(LabGantt$Name, levels = rev(unique(LabGantt$Name)))
# Set factor level to order the Position on the plot
LabGantt$Position <- as.factor(LabGantt$Position)
# Plot
plot_gantt <- qplot(xmin = Start,
xmax = End,
y = Name,
colour = Position,
geom = "linerange",
data = LabGantt,
size = I(5)) +
#scale_colour_viridis_d() +
scale_colour_manual(values = c("#2D708EFF" , "#DCE319FF", "#808080", "#20A387FF", "#482677FF")) +
theme_bw() +
scale_x_date() +
theme(panel.grid = element_blank()) +
geom_vline(xintercept=as.numeric(ymd("2019-01-01","2020-01-01", "2021-01-01")), linetype="dotted") +
xlab("") +
ylab("") +
ggtitle("MicroStats Lab")
# Repeat above for committees
CommitteeGantt$End[is.na(CommitteeGantt$End)] <- Sys.Date()
CommitteeGantt$Days <- CommitteeGantt$End - CommitteeGantt$Start
CommitteeGantt <- arrange(CommitteeGantt, Start, desc(Days))
CommitteeGantt$Name <- factor(CommitteeGantt$Name, levels = rev(unique(CommitteeGantt$Name)))
CommitteeGantt$Department <- as.factor(CommitteeGantt$Department)
plot_gantt_ctee <- qplot(xmin = Start,
xmax = End,
y = Name,
colour = Department,
geom = "linerange",
data = CommitteeGantt,
size = I(5)) +
#scale_colour_viridis_d() +
scale_colour_manual(values = c("#042333df", "#403891ff", "#a65c85ff", "#f68f46ff", "#efe350ff")) +
theme_bw() +
scale_x_date() +
theme(panel.grid = element_blank()) +
geom_vline(xintercept=as.numeric(ymd("2019-01-01","2020-01-01", "2021-01-01")), linetype="dotted") +
xlab("") +
ylab("") +
ggtitle("Committees")