Re: [R] Unable to specify order of a factor

2012-03-21 Thread David Winsemius
On Mar 21, 2012, at 1:07 PM, Justin Montemarano wrote: Hi all: I've got it... it appears that total.density was also defined in two separate data frames (se.predict.data and dc.predict.data) with levels order 16, 32, 8. Using relevel(), I moved 8 to the first position and it's solved the pl

Re: [R] Unable to specify order of a factor

2012-03-21 Thread Justin Montemarano
Hi all: I've got it... it appears that total.density was also defined in two separate data frames (se.predict.data and dc.predict.data) with levels order 16, 32, 8. Using relevel(), I moved 8 to the first position and it's solved the plotting problem. Ista's 'minimal' reproducible code request pr

Re: [R] Unable to specify order of a factor

2012-03-21 Thread R. Michael Weylandt
You'll also want to use dput() to send us an exact encoding of your data when making that reproducible example: there might be something subtle at play here that print methods won't show. Michael On Wed, Mar 21, 2012 at 12:28 PM, Ista Zahn wrote: > On Wed, Mar 21, 2012 at 12:00 PM, Justin Montem

Re: [R] Unable to specify order of a factor

2012-03-21 Thread Ista Zahn
On Wed, Mar 21, 2012 at 12:00 PM, Justin Montemarano wrote: > Ista: > > Your attached code did work for me; moreover, the facets were presented in > the desired order with facet_wrap() and facet_grid(), which is what I'm > using because I have a second factor used in facet_grid(). > > Still, my pl

Re: [R] Unable to specify order of a factor

2012-03-21 Thread Justin Montemarano
Ista: Your attached code did work for me; moreover, the facets were presented in the desired order with facet_wrap() and facet_grid(), which is what I'm using because I have a second factor used in facet_grid(). Still, my plots with total.density as a facet are coming out in 16, 32, 8, and I'm no

Re: [R] Unable to specify order of a factor

2012-03-21 Thread Ista Zahn
Hi Justin, this gives the correct order (8, 16, 32) on my machine: total.density <- c(8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32) total.density <- f

Re: [R] Unable to specify order of a factor

2012-03-21 Thread Justin Montemarano
I think I understand, but I believe my original interest is in the order of levels(total.density), since ggplot appears to be using that to order the facets. Thus, I'm still getting three graphs, ordered (and displayed as) 16 to 32 to 8, rather than the more intuitive, 8 to 16 to 32. I'm sorry if

Re: [R] Unable to specify order of a factor

2012-03-21 Thread Sarah Goslee
Ah, you're missing something crucial: > levels(total.density) [1] "8" "16" "32" is giving you the *labels* of the factor, as *strings*, and what you get if you use order() on them has nothing to do with the order of the factor levels, and everything to do with the string sort order for your loca

Re: [R] Unable to specify order of a factor

2012-03-21 Thread Justin Montemarano
Actually I've try that too, Sarah The test is to run order(levels(total.density)), which I need to be 1 2 3, not 2 3 1, and your solution still gives me 2 3 1. I also don't know how to reply to this thread with the previous message below... - Justin Montemarano Graduate Student Kent State Uni

Re: [R] Unable to specify order of a factor

2012-03-21 Thread Sarah Goslee
Is this what you need? > total.density <- + c(8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32) > total.density <- factor(total.density, levels=c(8, 16, 3

[R] Unable to specify order of a factor

2012-03-21 Thread Justin Montemarano
Hi all: I'm attempting to create a faceted plot with ggplot2 and I'm having issues with a factor's order that is used to define the facet_grid(). The factor (named total.density) has three levels - 8, 16, and 32 - and I would like them presented in that order. Running order(levels(total.density)