0
votes

I am plotting data by week using a lattice bwplot and am having trouble figuring out how it is deciding to sort the plots for each day. It showing (left to right, top to bottom): Tuesday, Wednesday, Friday, Monday, Thursday. Rather, I want it to show in the order of (left to right, top to bottom): Monday, Tuesday, Wednesday, Thursday, and Friday. Unfortunately I can't post an image to show the exact plot since I don't have a 10 reputation on SO.

Here are the first 6 rows of my data (the object is too big for dput). Imagine this repeating for 3,810 rows...

          X            datetime    useKW       genKW    netKW index     WkDay
22096 264719 2013-07-01 05:00:00 1.470133 0.003050000 1.467083 22096    Monday
22216 263279 2013-07-02 05:00:00 2.231567 0.002433333 2.229133 22216   Tuesday
22328 261839 2013-07-03 05:00:00 1.709833 0.003116667 1.706717 22328 Wednesday
22474 260399 2013-07-04 05:00:00 1.445117 0.003116667 1.442000 22474  Thursday
22607 258959 2013-07-05 05:00:00 1.428533 0.003116667 1.425417 22607    Friday
23002 254639 2013-07-08 05:00:00 1.528633 0.003233333 1.525400 23002    Monday
        HM   H_M
22096 0500 05:00
22216 0500 05:00
22328 0500 05:00
22474 0500 05:00
22607 0500 05:00
23002 0500 05:00

And, here is my function call for the bWplot:

bwplot(netKW~H_M|WkDay,data=DS1, scales=list(x=list(rot=45)), ylab='netKW', xlab=xlab, main=main)

I have looked into other posts about defining the lattice plot order and they seem to be leading to a common solution of changing the factor level order... In my case, it would be for WkDay. However, I am having trouble figuring out how to apply this to my specific problem.

1

1 Answers

1
votes
 DS1$WkDay <- factor( DS1$WkDay, levels=c( 'Monday', 'Tuesday', 'Wednesday', 
                                           'Thursday', 'Friday') )

You should realize that lattice plots are from bottom to top, so expecting it to be from top to bottom is swimming against the stream so to speak. See the as.table argument on the ?bwplot help page for a mechanism to alter that default behavior.