[R] Specifying strip names in xyplot (strip.custom)
Ahmed Attia
ahmedatia80 at gmail.com
Fri Jan 16 21:51:46 CET 2015
Hi R Users,
I would like to specify strip names in xyplot. I have 5 sources (S) and 3
locations (Loc). How I can force R to specifiy the strip names for each
source and location.
Below is my code;
S*Loc represents source by location. I do not know how to specify which
panel or factors.levels. In the code below, factor.levels represent three
Loc
Thanks for your help.
Ahmed
trellis.device(col=F)
xyplot(GrainM~Nrate|S*Loc, data = Ahmed,
layout=c(5,3,1),
xlab=expression(bold(paste("N rate (kg ", ha^-1,")"))),
ylab=expression(bold(paste("Grain yield (Mg ",ha^-1,")"))),
ylim=c(10,20),
strip=strip.custom(which.panel=3,factor.levels=c("Pierce","HAL","Concord"),strip.names=c(TRUE),strip.levels=c(TRUE),style=2,
par.strip.text = list(cex = 0.9)),
scales =
list(alternating=F,y=list(at=c(10,12,14,16,18,20,22)),font=2, cex=0.7,
col="black"),aspect = 1,
panel = function(x,y,subscripts,groups,...) {
#panel.grid(-1,-1)
m1 <- lm(y ~ x)
x.seq <- data.frame(x=seq(min(x)*0.95,max(x)*1.05,max(x)/10))
pred <- predict(m1, x.seq, se.fit=T)
grid.polygon(c(x.seq$x,rev(x.seq$x)),
c(pred$fit + 2*pred$se.fit, rev(pred$fit - 2*pred$se.fit) ),
gp=gpar(col=0, fill="light grey", alpha = 1), default.units =
"native")
llines(x.seq$x, pred$fit, lty = 1)
panel.xyplot(x,y)
print(round(summary(m1)$coef[ 2,c(1,4) ],3) )
ltext(50,18.4,paste("Slope = ",round(summary(m1)$coef[ 2,c(1,4)
],3),sep=""),
cex=0.65, adj=0)
ltext(50,19.5,paste("Intercept = ",round(summary(m1)$coef[ 1,c(1,4)
],3),sep=""),
cex=0.65, adj=0)
print(summary(m1))
}
)
Ahmed Attia, Ph.D.
*Agronomist & Soil Scientist*
Post-Doc Research Associate
Texas A&M AgriLife Research-Vernon
ahmed.attia at ag.tamu.edu
Cell phone: 001-979-248-5215
[[alternative HTML version deleted]]
More information about the R-help
mailing list