Skip to content

Instantly share code, notes, and snippets.

@chrissyhroberts
Created January 8, 2018 16:24
Show Gist options
  • Save chrissyhroberts/b629df27f113a9be0b49b0e49f8fa1ce to your computer and use it in GitHub Desktop.
Save chrissyhroberts/b629df27f113a9be0b49b0e49f8fa1ce to your computer and use it in GitHub Desktop.
Gantt chart
library(reshape2)
library(ggplot2)
#make csv file as below
#name,start.date,end.date,WP
#Task 1,1,10,1
#Task 2,2,8,1
#Task 3,12,16,2
#Task 4,22,32,2
#Task 5,18,22,3
#Task 6,12,36,3
#Task 7,1,24,3
#Task 8,23,24,4
tasks<-read.csv("gantt.csv",stringsAsFactors = T)
tasks$WP<-as.factor(tasks$WP)
mdfr <- melt(tasks, measure.vars = c("start.date", "end.date"))
ggplot(mdfr, aes(value, name, colour = WP)) +
geom_line(size = 6) +
ylab(NULL) +
xlab("Months") + scale_x_discrete() + theme_bw()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment