[R] Re - segments within a lattice graph

John.Gavin@ubsw.com John.Gavin at ubsw.com
Mon Jan 6 12:54:02 CET 2003


Hi,

The solution to my problem is to use
'lsegments' instead of 'segments' within lattice commands.

(Although I wont forget again, 
a comment in the segments help file referring to 'lsegments' 
might help others not to make the same mistake in the future.)

My thanks to Renaud Lancelot.

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


From: John.Gavin at ubsw.com
Date: Mon, 6 Jan 2003 09:08:28 -0000
To: <r-help at stat.math.ethz.ch>
Subject: [R] segments within a lattice graph

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)
)

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