2

I've data in a csv file with the following format :

start;duration
1;4
7;3
15;2

that's means we have 3 tasks, the first start at 1 and takes 4 seconds (so it end at 5), the second start a 7 and takes 3 second (soo ended at 10) and the last starts at 15 and take 2 seconds

How to reprensent these information in a graph which look like this enter image description here

Fopa Léon Constantin
  • 11,863
  • 8
  • 48
  • 82
  • 1
    See: http://stackoverflow.com/q/3550341/269476 and http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=74 – James Feb 22 '12 at 15:53

1 Answers1

8
 dat <- read.csv2(text="start;duration
 1;4
 7;3
 15;2
 ")
 plot(NA, xlim=c(0,20), ylim=c(0,9), ylab="",xlab="X", xaxt="n", yaxt="n")
 with(dat, segments(x0=start, x1=start+duration, y0=2,y1=2))
 with(dat, text( start+duration/2, 2.5, labels=duration))
 axis(1, at=seq(0,20,by=2), labels=seq(0,20,by=2))

You could obviously put in more descriptive labels for ylab and xlab in the plot call but this is what you get with that minimal example:

enter image description here

IRTFM
  • 258,963
  • 21
  • 364
  • 487