[R] re: help with lattice plot

From: <Eve.McDonald-Madden_at_dse.vic.gov.au>
Date: Tue 27 Jul 2004 - 12:51:06 EST


Dear List,

I have been using R to create an xyplot using the panel function within lattice libraries. This plot is based on the data supplied in R named 'Oats'. The graph represents oat yield by nitro level with an overlay of each variety of oats for each nitro level.

I have three questions regarding this graph: 1) I cannot seem to specify the type of symbol used by the plot, even though it is included in the code below, it will change when the code is changed?
2) I have managed to include a legend on the graph using the key function; however the labels of the legend do not seem to correspond to the right coloured symbol as used in the plot itself for Variety. How can I get the symbols and text in the legend to match that used in the graph itself? 3) Also, I am interested to know how I can manipulate the order in which each graph (in this instance Nitro level) appears? For example, at the moment the graphs do not appear in numerical order (based on the levels of the factor nitro) can I reorder them so that they appear in the order I, II, III,

                                                             IV,  V,   VI
?

The code I have used is included below:

##Data

library(nlme)
data(Oats)

##Factors

Oats$Block<-factor(Oats$Block)
Oats$Variety<-factor(Oats$Variety)
Oats$nitro<-factor(Oats$nitro)

attach(oats)

##Plot

library(lattice)
lset(col.whitebg())
xyplot(yield~nitro|Block, data=Oats,xlab="Nitrogen Level",ylab="Yield of oats",subscripts=T, groups=Oats$Variety, as.table=T, panel=function(x,y,groups,subscripts){
panel.superpose(x=x, y=y, groups=Oats$Variety, subscripts=subscripts,pch=18)
panel.superpose(x=x, y=y, groups=Oats$Variety, subscripts=subscripts, type ="r")
}
,key = list(points = Rows(trellis.par.get("superpose.line"),c(1:2,3)),text = list(lab = as.character(unique(Oats$Variety))),pch=18) )

I would greatly appreciate anyone's time in assisting me with this request.

I look forward to your reply

Regards

Eve

Eve McDonald-Madden
Fauna Ecology
Arthur Rylah Institute for Environmental Research Heidelberg, Victoria.Australia
Email: eve.mcdonald-madden@nre.vic.gov.au



R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue Jul 27 13:00:36 2004

This archive was generated by hypermail 2.1.8 : Fri 18 Mar 2005 - 02:39:21 EST