[R] segments within a lattice graph

John.Gavin@ubsw.com John.Gavin at ubsw.com
Mon Jan 6 10:10:03 CET 2003


Hi,

I would like to use the segments command 
within a lattice graph. 
Is this allowed in R in the same way as in SPlus?
If not, what is the alternative?

For example, the following produces vertical
line segments between points in SPlus
but in R the line segments are not shown.
(I want to replicate in R what I see in SPlus.)
What is my mistake?

library(lattice)
set.seed(123)
dat <- data.frame(
aa = runif(10),
bb = runif(10),
cc = runif(10)
)
dat <- dat[order(dat$aa),]
dat
xyplot(cc ~ aa, data = dat,
 panel = function(x, y, ...)
 { # no line segements and no error is printed.
   segments(dat$aa, dat$bb, dat$aa, dat$cc)
   panel.xyplot(dat$aa, dat$cc, col = 1, pch = 1, type = "b")
   panel.xyplot(dat$aa, dat$bb, col = 2, pch = 2, type = "b")
   # no arrows but errors are printed.
   # arrows(dat$aa, dat$bb, dat$aa, dat$cc)
 }, ylim = range(dat$bb, dat$cc)
)

SPlus 6.0.5 R4 for MS Windows NT4 SP5
R 
platform i386-pc-mingw32
arch     i386           
os       mingw32        
system   i386, mingw32  
status                  
major    1              
minor    6.1            
year     2002           
month    11             
day      01             
language R        

Regards,

John.

John Gavin <john.gavin at ubsw.com>,
Quantitative Risk Models and Statistics,
UBS Warburg, 6th floor, 100 Liverpool St.,
London EC2M 2RH, UK.
Phone +44 (0) 207 567 4289
Fax   +44 (0) 207 568 5352

Visit our website at http://www.ubswarburg.com

This message contains confidential information and is intended only 
for the individual named.  If you are not the named addressee you 
should not disseminate, distribute or copy this e-mail.  Please 
notify the sender immediately by e-mail if you have received this 
e-mail by mistake and delete this e-mail from your system.

E-mail transmission cannot be guaranteed to be secure or error-free 
as information could be intercepted, corrupted, lost, destroyed, 
arrive late or incomplete, or contain viruses.  The sender therefore 
does not accept liability for any errors or omissions in the contents 
of this message which arise as a result of e-mail transmission.  If 
verification is required please request a hard-copy version.  This 
message is provided for informational purposes and should not be 
construed as a solicitation or offer to buy or sell any securities or 
related financial instruments.




More information about the R-help mailing list