[R] Lattice graphics with combined plot types
Deepayan Sarkar
deepayan.sarkar at gmail.com
Thu Dec 15 17:05:34 CET 2005
On 12/15/05, Shawn Way <Shawn.Way at biogenidec.com> wrote:
> The data is of two forms, ie one numeric and another ordinal ie 1.5 and
> <.5. The X Value is a factor.
>
> I'm trying to create a lattice conditioned plot with the following
> characteristics:
>
> 1) The plot is conditioned using the form (Conductivity~Day|Valve)
> 2) The plot should use a barplot for the ordinal (<.5) and dots for the
> numeric (1.5)
> 3) A line should be created specifying a limit (ie 0.5)
>
> What I would like is the bar on Day 3 to be a dot at 0.5 (a red one would
> be even better)
>
>
> I have the following working:
>
> data <-
> data.frame(Conductivity=c(.24,.24,.5),Day=as.factor(c(1,2,3)),Valve=as.factor(c("60-V-234","60-V-234","60-V-234")))
>
> print(barchart(Conductivity~Day|Valve,
> data=data,
> horizontial=FALSE,
> # type="p",
> xlab=list(label="Day",cex=3),
> ylab=list(label=expression(paste("Endotoxin (EU/mL)")),cex=3),
> ylim=c(0,1),
> # index.cond=list(c(2,1)),
> scales=list(x=list(rot=90,cex=2),y=list(cex=2))
> ,panel=function (x,y,...) {
> panel.barchart(x,y,...)
> panel.abline(h=0.25,col="red")
> }
> # main="Stable Pressure for 70-DS-005 Protocol 02-634-02B"
> )
> )
You seem to have used a cutoff of 0.25 (rather than 0.5) in your example.
> Any thoughts? I know it's something simple, I just cannot see it...
How about
panel=function (x, y, ...) {
below <- y < 0.25
if (any(below))
panel.barchart(x[below], y[below], ...)
if (any(!below))
panel.xyplot(x[!below], y[!below], ...,
col = 'red', cex = 2, pch = 16)
panel.abline(h=0.25,col="red")
}
?
Deepayan
--
http://www.stat.wisc.edu/~deepayan/
More information about the R-help
mailing list