[R] Order of boxplots
li li
hannah.hlx at gmail.com
Tue Sep 15 22:04:55 CEST 2015
Thank you! That worked.
2015-09-15 2:50 GMT-04:00 peter dalgaard <pdalgd at gmail.com>:
>
> > On 15 Sep 2015, at 04:31 , li li <hannah.hlx at gmail.com> wrote:
> >
> > Hi Jeff,
> > Thanks for replying. I actually tried "ordered(tmp$type, levels=c("c",
> > "b", "a")."
> > But I think only the order of the letters on x axis changed but the order
>
> You _think_ ??? Documentation, please...
>
> The boxplots certainly move if I do
>
> plot(result ~ type, tmp)
> plot(result ~ factor(type, levels=c("c","b","a")), tmp)
>
>
>
> > of the boxplot did not. So there is some problem there. I also tried
> > as.factor(tmp$type); levels(tmp$type)=c("c", "b", "a") and got the same
>
> That changes the level _names_: 1st group name becomes "c" instead of "a";
> you want the 3rd group to become the 1st but still be called "c".
>
> -pd
>
>
> > thing.
> > Thanks.
> > Li
> >
> > 2015-09-14 21:44 GMT-04:00 Jeff Newmiller <jdnewmil at dcn.davis.ca.us>:
> >
> >> Make your factor variable deliberately. That is, specify the levels
> >> parameter with the values in order when you create the factor.
> >>
> ---------------------------------------------------------------------------
> >> Jeff Newmiller The ..... ..... Go
> Live...
> >> DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live
> >> Go...
> >> Live: OO#.. Dead: OO#.. Playing
> >> Research Engineer (Solar/Batteries O.O#. #.O#. with
> >> /Software/Embedded Controllers) .OO#. .OO#.
> rocks...1k
> >>
> ---------------------------------------------------------------------------
> >> Sent from my phone. Please excuse my brevity.
> >>
> >> On September 14, 2015 6:23:50 PM PDT, li li <hannah.hlx at gmail.com>
> wrote:
> >>> Hi all,
> >>> I have the following data "tmp" and I want to plot boxplots for
> >>> each level of the factor "type" and the order the factor should be c,
> >>> b ,a. In other words, the boxplot corresponding to the level "c"
> >>> should be the first and so on.
> >>> Any suggestions?
> >>> Li
> >>>
> >>>> tmp
> >>> result type
> >>> 1 101 a
> >>> 2 101 a
> >>> 3 101 a
> >>> 4 101 a
> >>> 5 101 a
> >>> 6 101 a
> >>> 7 100 a
> >>> 8 106 b
> >>> 9 91 b
> >>> 10 78 b
> >>> 11 95 b
> >>> 12 111 b
> >>> 13 92 b
> >>> 14 98 b
> >>> 15 108 c
> >>> 16 112 c
> >>> 17 98 c
> >>> 18 102 c
> >>> 19 88 c
> >>> 20 86 c
> >>> 21 81 c
> >>>
> >>> ______________________________________________
> >>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >>> 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.
> >>
> >>
> >
> > [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > 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.
>
> --
> Peter Dalgaard, Professor,
> Center for Statistics, Copenhagen Business School
> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
> Phone: (+45)38153501
> Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
>
>
>
>
>
>
>
>
>
[[alternative HTML version deleted]]
More information about the R-help
mailing list