[R] R help: reorder columns in an xyplot

rent0009 at umn.edu rent0009 at umn.edu
Mon Nov 8 04:35:35 CET 2010


Hello. First post, though I have read scores. Mostly i can solve my 
problems reading the archives, but I lack the vocabulary to ask this one 
right. Any social faux pais, I apologize.

I am sure this is a very basic question and I am embarrassed to ask, but I 
spent several hours scouring the archives and trying various suggestions, 
but I am too new to get any of them to work.

I am trying to generate an xyplot (or bwplot) for a presentation on 
Tuesday. As part of my dissertation I have 3 treatments divided into 2 time 
periods (before and after treatment).

Code that works (stripped of labels) is:

xyplot(veg$litter_depth ~ veg$status | veg$treatment, layout=c(3,1), 
type=c("p","r"))

Status is "before" and "after" In essence I am plotting a change in litter 
depth (and about 50 other variables) over time for each of the treatments. 
This generates a graph with 3 separate plots, one for each treatment. The 
plot works, but after is on the left and before on the right. This bugs me.

I tried:
veg$status2 <- reorder(veg$status, new.order=c("before", "after"))
but get:
Error in length(X) : 'X' is missing

I also tried:
h <- xyplot(litter.cover ~ status | treatment, relevel(status, 
ref=c("before", "after")), data = veg)

but get:
Error in relevel(status, ref = c("before", "after")) : 
  object 'status' not found

I have noticed that folks request data, but I hope my question is basic 
enough without it.

Please be gentle and thank you in advance,

Mike.


-- 
Michael S. Rentz
PhD Candidate, Conservation Biology
University of Minnesota
rent0009 at umn.edu



More information about the R-help mailing list