[R] factors as bwplot x axis
James Rome
jamesrome at gmail.com
Fri Apr 16 02:39:45 CEST 2010
Dear List,
I am having problems getting my box and whisker plots to put boxes on
the right x-axis values.
x is the hour of the day from 0 to 23.
> unique(mdf$OnHour)
[1] 5 4 6 7 11 12 9 8 19 14 13 21 20 10 18 17 15 16 23 22 0 1 3 2
mdf$OnHFact = factor(mdf$OnHour, levels=seq(0,23),
labels=as.character(seq(0,23)), exclude=NULL, ordered=TRUE)
I know there are data points for OnHFact=="0", but they do not appear on
the plot. The other data seem to be at their correct locations.
hrs = seq(0, 23, 1)
hrlabs = as.character(seq(0,23,1))
g = bwplot((gdf$tt)~gdf$OnHFact | gdf$Runway, data=gdf,
ylab="Taxi time (min)",
main=title, xlab="Hour of day",
par.strip.text=list(cex=0.7), rot=90, #xlim=c(0, 24),
scales=list(x = list(rot=90, cex=.6, at=hrs, labels=hrlabs )),
panel = function(x, ...) {
panel.grid(h = -1, v = -1)
panel.bwplot(x, ...)
} )
print(g)
Is there a prohibition of having a factor with a level of 0? If so, how
do I get around this?
I was also surprised that if I replace gdf$OnHFact by gdf$OnHour
(integers) in the above bwplot call, the plot flips and I get horizontal
whiskers of OnHour values for different tts.
So I am confused, and hope you kind people can help. I attach the zipped
dput gdf file
Thanks,
Jim Rome
More information about the R-help
mailing list