This toy example works as you seem to expect:
library(ggplot2)
dat - data.frame(time = factor(rep(0:59, each = 100), levels = 0:59),
error = rnorm(6000))
qplot(time, error, data = dat, size = I(1), main = title,
ylab=Error (min), xlab=Time before ON (min), alpha=I(1/10),
geom=jitter) +
geom_boxplot(alpha=.5, color=blue, outlier.colour=green,
outlier.size=1) +
scale_x_discrete(breaks = seq(from=0, to=60, by=10))
sessionInfo()
R version 2.13.0 Patched (2011-04-19 r55523)
Platform: x86_64-pc-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets grid methods
[8] base
other attached packages:
[1] raster_1.8-31 geoR_1.6-35 sp_0.9-81 googleVis_0.2.5
[5] RJSONIO_0.5-0 sos_1.3-0 brew_1.0-6 lattice_0.19-26
[9] ggplot2_0.8.9 proto_0.3-9.2 reshape_0.8.4 plyr_1.5.2
loaded via a namespace (and not attached):
[1] digest_0.5.0 tools_2.13.0
I don't see any of the problems that you've experienced, so you should
provide a minimal reproducible example that illustrates the problem -
it doesn't have to be your actual data, just something that mimics it
and reproduces the error you're seeing. There's likely to be something
in the way your data are constructed that generates the error, but
since you failed to provide it, who can tell?
Q: Why do you have levels 0 to 60 instead of either 0 to 59 or 1 to
60? Do you think that might be the cause of the problem?
Dennis
On Fri, Jun 10, 2011 at 11:08 AM, James Rome jamesr...@gmail.com wrote:
I am trying to overlay raw data with a boxplot as follows:
pp = qplot(factor(time, levels=0:60, ordered=TRUE),
error, data=dfsub, size=I(1), main = title, ylab=Error
(min),
xlab=Time before ON (min), alpha=I(1/10),
ylim=c(-30,40), geom=jitter) +
facet_wrap(~ runway, ncol=2) +
geom_boxplot(alpha=.5, color=blue, outlier.colour=green,
outlier.size=1) +
scale_x_discrete(breaks = seq(from=0, to=60, by=10))
print(pp)
But I think ggplot2 is getting confused about factors versus numbers
sapply(dfsub,class)
time error runway flight
numeric numeric factor factor
because when I do the plot, the vertical grid lines are in pairs, one
line at (0, 10, 20,...) and the other at (-1, 9, 19,)
If I remove the scale_x_discrete, I get a grid line at every minute,
and things look right, but the labels for the minutes all overlap.
Thanks for the help,
Jim Rome
__
R-help@r-project.org 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.
__
R-help@r-project.org 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.