[R] Customised legend in lattice

2003-09-10 Thread Alexander . Herr
Hi List,

Am trying to customize a legend in trellis: Draws 2x5 lines in 5 colors and
2 linetypes. I would like to add two more items to the legend showing the
key for the line types above the colored legend.

Any suggestions welcome - thanks Herry

#
#Following example code:

library(gregmisc)
trellis.device(bg=white)
i1=0
i2=-1.89767506
i3=-1.17087085 
i4=-0.09853587
i5=0.87486320
a1=1.9106842
a2=0.7518519
x1-seq(0,7, by=0.01)


y1-inv.logit(a1+a2*(x1)+i1)
y2-inv.logit(a1+a2*(x1)+i2)
y3-inv.logit(a1+a2*(x1)+i3)
y4-inv.logit(a1+a2*(x1)+i4)
y5-inv.logit(a1+a2*(x1)+i5)

z1-inv.logit(a2*(x1)+i1)
z2-inv.logit(a2*(x1)+i2)
z3-inv.logit(a2*(x1)+i3)
z4-inv.logit(a2*(x1)+i4)
z5-inv.logit(a2*(x1)+i5) 
as.data.frame(cbind(y1,y2,y3,y4,y5,z1,z2,z3,z4,z5))-tmp


leg.txt-c(Rating 1,Rating 2,Rating 3,Rating 4,Rating 5)
colo-rep(c(black,red,darkgreen,navyblue,rosybrown),2)

plot4-xyplot(y1+y2+y3+y4+y5+z1+z2+z3+z4+z5~x1, cex=2, xlab=number x,
ylab=Probability, 
bg=white, xlim=c(0,7), ylim=c(0,1), type=l,
allow.multiple=TRUE, 
data=tmp,
panel=function(x,y,subscripts,...){
 for(i in 1:5){
  panel.xyplot(x1,tmp[,i],col=colo[i],lwd=2,lty=1,...)
 }
 for(i in 6:10){
  panel.xyplot(x1,tmp[,i],col=colo[i],lwd=2,lty=2,...)
 }

}
 )

update(plot4, key = list(corner=c(0,1), x=0.65, y=0.35,
  points=list(c(1:5),col=colo[1:5],pch=19),
text=list(leg.txt),
 )
   ) 

##--- Not working part--XXX
update(plot4, key = list(corner=c(0,1), x=0.65, y=0.35,
  lines=list(c(1:2),col=black,lwd=1,lty=c(1:2)),
text=list(c(category 1,category 2)),
  points=list(c(1:5),col=colo[1:5],pch=19),
text=list(leg.txt),
 )
   ) 



Alexander Herr - Herry
Northern Futures
Davies Laboratory
PMB, Aitkenvale, QLD 4814
Phone (07) 4753 8510
Fax   (07) 4753 8650
Home: http://batcall.csu.edu.au/~aherr
Webadmin ABS: http://ausbats.org.au
Sustainable Ecosystems: http://www.cse.csiro.au/



[[alternative HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] trellis.graphic in for-loop

2003-04-04 Thread Alexander . Herr
Hi list,

I am unsuccessfully trying to produce a serious of trellis barcharts from
within a for-loop. The barcharts work outside the loop. What am I missing?
Example attached.

Thanks Herry

#XX


trellis.device(bg=white)
trellis.par.get(fontsize)-fontsize
fontsize$default-16
trellis.par.set(fontsize,fontsize)

a-c(1,2,4,5,4,3,3,3)
b-c(2,5,1,1,1,3,3,3)
c-c(3,5,1,2,2,5,5,5)
as.data.frame(cbind(a,b,c))-q21
varnames-colnames(q21)
i-
for (i in 1:3) {
round(table(q21[,i])/sum(table(q21[,i])),3)*100-z1
 as.data.frame.table(table(q21[,i]))-z1
  round(z1[,2]/sum(z1[,2]),3)*100-z1[,2]
   colnames(z1)-c(varnames[i],y)
   xnames-levels(z1[,1])
paste(xnames[1], - low,sep=)-xnames[1]
 paste(xnames[length(xnames)], - high,sep=)-xnames[length(xnames)]
  z1[,1]-xnames
 as.factor(z1[,1])-z1[,1]
barchart(
  horizontal=FALSE,
   z1[,2]~z1[,1],
ylab=list(% frequency,cex=1.5),
 main=list(varnames[i],cex=1.25),
scales=list(1,cex=1.5), col=#ffd18f,
   sub=list(Rating,cex=1.25)
)
filename-paste(test,i,_q21k.jpg,sep=)
#dev.print(jpeg, filename , width=1000, height=1000, quality=100,
bg=white, pointsize=20)
}


[[alternate HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] extracting data.frame names for list

2003-01-15 Thread Alexander . Herr
Hello List,

I want to extract the names of a data.frame into a list for passing on to
listing in aggregate eg

names(df)[-1]-varnames
names(df)[1]-resvar
aggregate(resvar,by=list(list of varnames),length)

I am unsuccessfull in translating varnames into the list of varnames using
paste,c,cat etc Anyone able to help?

Thanks Herry


Alexander Herr - Herry

[[alternate HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help