Lattice barchart-reordered

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Lattice barchart-reordered

Veerappa Chetty
Hi,Can I use "reorder" function with barchart as in dotchart? Here are some
codes which do not work for  me. Thanks
Chetty
___________________________
a1c.cast$bmi.cat.reordered[a1c.cast$eth!="Other"]
<-with(a1c.cast[a1c.cast$eth!="Other",],reorder(bmi.cat.ordered[a1c.cast$eth!="Other"],
BP.FN.RATE,median ))
barchart(BP.FN.RATE~
gender|eth,data=a1c.cast[a1c.cast$eth!="Other"&a1c.cast$bmi.cat.reordered!="Other",],
groups =bmi.cat.reordered ,
par.settings = list(superpose.polygon =
list(col=c("blue","cyan","red","yellow" )) ),
sub="  NHANES-99:06; n = 12,514 " ,ylab= list("Error Rate (%)",cex=1.5),
xlab=list("Gender",cex=1.25),auto.key=list(title=" FPG VS A1C for DM
Diagnosis: Missed BP",columns=2,cex=1.25),
col=c("blue","cyan","red","yellow"))

--
Chetty
Professor of Family Medicine
Boston University
Tel: 617-414-6221, Fax:617-414-3345
emails: [hidden email],[hidden email]

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Lattice barchart-reordered

Dieter Menne

Veerappa Chetty wrote
Hi,Can I use "reorder" function with barchart as in dotchart? Here are some
codes which do not work for  me.
.. example remove
As your example is not self-contained (it should be), I cannot show it with your data.
My preferred way is to reorder outside, because it enforces consistency when I do several plots.

Dieter

library(lattice)
barchart(yield ~ variety | site, data = barley,
         groups = year, layout = c(1,6),
         ylab = "Barley Yield (bushels/acre)",
         scales = list(x = list(abbreviate = TRUE,
                       minlength = 5)))
                       
levels(barley$site) = c( "Waseca","Grand Rapids","Duluth","University Farm","Morris" ,
  "Crookston"  )
 
barchart(yield ~ variety | site, data = barley,
         groups = year, layout = c(1,6),
         ylab = "Barley Yield (bushels/acre)",
         scales = list(x = list(abbreviate = TRUE,
                       minlength = 5)))