[R] xyplot question

Peter Alspach PAlspach at hortresearch.co.nz
Wed Sep 19 02:02:22 CEST 2007


Raymond

I had the same question a while ago and found the answer by typing

RSiteSearch('xyplot error bars')

Peter Alspach
 

> -----Original Message-----
> From: r-help-bounces at r-project.org 
> [mailto:r-help-bounces at r-project.org] On Behalf Of Raymond Balise
> Sent: Wednesday, 19 September 2007 10:52 a.m.
> To: r-help at stat.math.ethz.ch
> Subject: [R] xyplot question
> 
> I am tring to add error bars to data in an xyplot.  Below is 
> the content of a CSV file that I am trying to use and the 
> code which plots the data points and 45 degree lines in each 
> of the panes of the trellice.  I want to add error bars that 
> go up and down to the limits set by the lcl and ucl values in 
> the data set.  How the heck can I specify the error bars in a 
> lattice plot?
> 
> If anyone knows how to do this can you please tell me how to 
> do it and more importantly point me toward a book/paper that 
> explains how to do this and has examples. :~)  As always, 
> help is profoundly appreciated.
> 
> fig2 = read.xls("figure2.csv")
> 
> library(lattice)
> library(grid)
> 
> with(fig2,
>           xyplot(y ~ x |  group * Method,
>           xlab = "",
>           xlim = c(-5, 1),
>           ylab = "",
>           ylim = c(-5, 1),
>           col = "black",
>           groups = group,
>           aspect = 1,
>           lx = lcl,
>           ux = ucl,
>           pch = 16 ,
>           panel = function(x, y, ...) {
>              panel.superpose(x, y, ...)
>              panel.abline(0, 1)
> 
>          },
>          )
> )
> 
> ###### some sample data for a CSV file ############
> 
> Method,group,x,y,lcl,ucl
> A,Black,-3.018626791,-1.461326791,-2.068936791,-0.867106791
> A,Black,-3.304632403,-2.608322403,-3.463632403,-1.768972403
> A,Black,-2.673500283,-2.100820283,-2.708560283,-1.507230283
> A,Black,-1.700734807,-0.887104807,-1.275424807,-0.524394807
> A,Black,-0.586121342,-0.848638342,-1.169118342,-0.551044342
> A,Yellow,-3.136580929,-1.120380929,-1.720710929,-0.550799929
> A,Yellow,-2.757574147,-1.021674147,-1.474644147,-0.600298147
> A,Yellow,-2.17890461,-0.89563461,-1.34797461,-0.47309861
> A,Yellow,-1.812551095,-0.920201095,-1.215711095,-0.639398095
> A,Yellow,-1.054284002,-1.195239002,-1.453922002,-0.956836002
> A,Green,-1.639312507,-4.174222507,-4.174222507,-4.174222507
> A,Green,-1.23917727,-0.30492427,-0.68852327,-0.21611447
> A,Green,-0.66966805,-1.13230605,-1.99186605,-0.49901105
> A,Green,0.278895635,0.096514635,-0.301298365,0.300602935
> A,Green,-0.504911532,-0.894806332,-1.378339332,-0.603663332
> A,Blue,-2.969196277,-3.693096277,-3.820696277,-1.384526277
> A,Blue,-2.419573959,-2.280913959,-2.894093959,-1.672893959
> A,Blue,-1.773659064,-1.850719064,-2.450169064,-1.260569064
> A,Blue,-1.510092543,-0.851495543,-1.439472543,-0.411152543
> A,Blue,-0.595168746,-0.998596746,-1.208087746,-0.805696746
> B,Black,-2.459224263,-1.757114263,-2.364714263,-1.162324263
> B,Black,-1.817291831,-1.704651831,-2.557361831,-0.868041831
> B,Black,-2.495591512,-2.614881512,-3.456411512,-1.789931512
> B,Black,-1.216945891,-0.928095891,-1.315455891,-0.557498891
> B,Black,-0.500977651,-0.518668651,-0.817970651,-0.249855651
> B,Yellow,-2.473182951,-1.310892951,-1.909672951,-0.741403951
> B,Yellow,-2.085555297,-0.856005297,-1.252555297,-0.489987297
> B,Yellow,-2.249602851,-1.539112851,-2.010652851,-1.093110851
> B,Yellow,-1.406241001,-0.872741001,-1.183891001,-0.577481001
> B,Yellow,-0.953045757,-0.981668757,-1.241857757,-0.740871757
> B,Green,-2.487720209,-4.310240209,-4.310240209,-4.310240209
> B,Green,-2.472235352,-0.579902352,-0.963501352,-0.491092552
> B,Green,-1.35388464,-0.39377464,-0.99212464,0.00267836
> B,Green,-1.20222519,-0.58276419,-1.05847819,-0.30239519
> B,Green,-0.155542679,-0.302979679,-0.795866679,-0.000590679
> B,Blue,-2.467137219,-2.879317219,-3.541517219,-2.219037219
> B,Blue,-2.093208678,-2.467378678,-3.037568678,-1.901558678
> B,Blue,-1.968546702,-1.171728702,-1.881726702,-0.642598702
> B,Blue,-1.067931387,-1.109401387,-1.445171387,-0.785811387
> B,Blue,-0.936799562,-1.166112562,-1.361216562,-0.987562562
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 

___________________________________________________________________
The contents of this e-mail are privileged and/or confidential to the
named recipient and are not to be used by any other person and/or
organisation. If you have received this e-mail in error, please notify
the sender and delete all material pertaining to this e-mail.



More information about the R-help mailing list