[R] xyplot() - can you control how the plots are ordered?

AR anandram at gmail.com
Sun Mar 8 07:05:24 CET 2009


I want to control the plots in the output of the xyplot(). It is
easier to explain it through an example:

# months
months <- c("Jan", "Feb", "Mar",
           "Apr", "May", "Jun",
           "Jul", "Aug", "Sep",
           "Oct", "Nov", "Dec");

n <- length(months);
m <- 10;

mdata <- data.frame(x = runif(m*n), y = runif(m*n), z = rep(months,
each = m));
h <- xyplot(y ~ x | z, data = mdata);

The output of the xyplot() is sorted by the alphabetical order of
months (First Apr, then Aug so on). I need to output such that the
order of the months is maintained, i.e. plot of Jan first, then Feb,
Mar ... so on.

I tried searching on the web and I couldn't find any or probably
didn't understand. I would be much obliged if someone could help.


More information about the R-help mailing list