[R] Unordered Factors For ggplot?

Juliet Hannah juliet.hannah at gmail.com
Sun Feb 21 18:34:34 CET 2010


It would be easier with some example data. Make sure the data is represented by
factors and check the levels and relevel if needed. Something like:

df$day <- factor(df$day, levels = c("30", "29", "20))

Also search the ggplot2 mailing list for factor and order. I think
similar questions
are asked often (although I may not be interpreting your question correctly).



On Wed, Feb 17, 2010 at 1:50 PM, Ryan Garner
<ryan.steven.garner at gmail.com> wrote:
>
> I have data that comes into R already ordered. When I use ggplot, it orders
> them which I don't want. How do I fix this without changing
> options("contrast")?
>
> The data I have is number of days:
> 30
> 29
> ...
> 20
> 19
> ...
> 10
> 9
> ...
> 1
>
> When I plot with ggplot, it orders them by the first number only. So 3 ends
> up coming before 29.
> --
> View this message in context: http://n4.nabble.com/Unordered-Factors-For-ggplot-tp1559146p1559146.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at 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.
>



More information about the R-help mailing list