[R] Lattice graph with segments

Tim Churches tchur at optushome.com.au
Sat Dec 4 21:40:52 CET 2004


Andrew Robinson wrote:
> Ruud,
> 
> try something like the following (not debugged, no coffee yet):
> 
> 
> xyplot(coupon.period ~ median, data=prepayment,
>  subscripts=T,	     
>  panel=function(x,y,subscripts,...){
>    panel.xyplot(x,y)
>    panel.segments(deel1$lcl[subscripts], deel$ucl[subscripts])
>  }
> )
> 

Andrew Robinson wrote:
 > Ruud,
 >
 > try something like the following (not debugged, no coffee yet):
 >
 >
 > xyplot(coupon.period ~ median, data=prepayment,
 >  subscripts=T,	
 >  panel=function(x,y,subscripts,...){
 >    panel.xyplot(x,y)
 >    panel.segments(deel1$lcl[subscripts], deel$ucl[subscripts])
 >  }
 > )
 >

Not quite:

library(lattice)
prepayment <- data.frame(median=c(10.89,12.54,10.62,8.46,7.54,4.39),
                          ucl=c(NA,11.66,9.98,8.05,7.27,4.28),
                          lcl=c(14.26,13.34,11.04,8.72,7.90,4.59),
                          coupon.period=c('a','b','c','d','e','f'))

xyplot(coupon.period ~ median, data=prepayment,
  subscripts=T,	
  panel=function(x,y,subscripts,...){
    panel.xyplot(x,y)
    panel.segments(prepayment$lcl[subscripts], prepayment$ucl[subscripts])
  }
)

throws the error:

Error in max(length(x0), length(x1), length(y0), length(y1)) :
         Argument "x1" is missing, with no default

Tim C




More information about the R-help mailing list