Drawing Gantt charts with R to sub-second accuracy -
slightly bizarre request, know, bear me.
i have excel spreadsheet logging data taken highly parallelised bit of server-side code. i'm trying analyse there may gaps in logs, indicating tasks should logged aren't; because it's serial, timestamp-order list of dozen or parallel threads it's quite hard read. had unorthodox idea of using gantt chart visualise overlapping tasks. excel terrible @ this, started looking @ alternative tools, , thought of trying r.
each task in log has start timestamp, , end timestamp, , duration, have data need. read this post , mutilated example r script:
tasks <- c("task1", "task2") dfr <- data.frame( name = factor(tasks, levels = tasks), start.date = c("07/08/2013 09:03:25.815", "07/08/2013 09:03:25.956"), end.date = c("07/08/2013 09:03:28.300", "07/08/2013 09:03:30.409"), is.critical = c(true, true) ) mdfr <- melt(dfr, measure.vars = c("start.date", "end.date")) ggplot(mdfr, aes(as.date(value, "%d/%m/%y %h:%m:%os"), name, colour = is.critical)) + geom_line(size = 6) + xlab("") + ylab("") + theme_bw()
this doesn't work, though -- doesn't plot data, , time axis messed up. suspect (unsurprisingly) plotting sub-second gantt charts weird thing do. i'm complete r newbie (although i've been looking excuse try out ages) -- there simple way make work?
first, time should in posixct
format not date
contains hours , minutes. can add new column melted dataframe correct format.
mdfr$time<-as.posixct(strptime(mdfr$value, "%d/%m/%y %h:%m:%os")
)
then scale_x_datetime()
can control breaks on axis. x values use new column correct format.
library(scales) ggplot(mdfr, aes(time,name, colour = is.critical)) + geom_line(size = 6) + xlab("") + ylab("") + theme_bw()+ scale_x_datetime(breaks=date_breaks("2 sec"))
Comments
Post a Comment