[R] Plot time range with rect or boxplot

Eric Hu Eric.Hu at gilead.com
Sat Oct 9 21:10:06 CEST 2010


Hi,
I am trying to use rect (R2.11) to plot a set of data as following
 
 
 > data
  Company        Pt                  Pri                  Pub
1    A            WO520          8/5/09          2/11/10
2    B            WO893         7/30/03          2/24/05
3    A            WO258         12/8/08          6/17/10
4    C           WO248         1/13/09           9/2/10


pri<- strptime(pri,"%m/%d/%y")
pub <- strptime(pub,"%m/%d/%y")

plot.new()
plot.window(xlim=c(min(pri,pub),max(pri,pub)),ylim=c(0,length(company)-1))
%y <- seq(0,0.5*(length(company)-1),0.5)
%h <- 0.1
%rect(pri, y-h, pub, y+h, col=c("light blue","pink","yellow","red"))
 
Neither xlim nor rect/boxplot recognizes pri/pub with date format. I wonder if there is a good way to deal with the date ploting so the x-axis can reflect the actual time range.
 
Thank you,
Eric


More information about the R-help mailing list