Created
October 14, 2013 14:58
-
-
Save natbusa/6977041 to your computer and use it in GitHub Desktop.
A gist about displaying intervals using R and ggplot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library("ggplot2") | |
logfile = " | |
task a,2,9 | |
task b,3,8 | |
task c,1,4 | |
task d,5,12 | |
" | |
# read in the sample logfile in a data frame | |
df = read.csv( | |
text=logfile, | |
header=FALSE, | |
sep = ",", | |
stringsAsFactors=FALSE, | |
blank.lines.skip=TRUE | |
) | |
# give the column a proper name | |
names(df)=c('name', 'start','end') | |
# display the timeline intervals sorted by start time | |
# display the timeline intervals sorted by start time | |
ggplot(df, aes(start, reorder(name, -start), colour = name)) + | |
geom_errorbarh(aes(xmin = start,xmax = end, height = 0.2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment