[R] sorting in barplot
Romain.Mayor at ville-ge.ch
Romain.Mayor at ville-ge.ch
Wed May 2 17:36:03 CEST 2007
Thank you for your answer,
But I think it doesn't work, because the function "bargraph.CI" (I use it
because barplot doesn't have a standard error option) use two internally
function(one for mean and the other for standard error) which use something
like tapply (which sort the factors by alphabet). If I decompose the two
function and than reorder one time with mean and one other time with
standard error, so it doesn't match on the graph.
I try also so: bargraph.CI(x.factor = REGION, response = MOY_FST, data =
Fst2,ylab = "Average Fst by pair of
populations",reorder(Fst2$REGION,Fst2$MOY_FST,mean))
with tihs Fst2 table:
REGION MOY_FST
1 AR 0.039
2 AR 0.040
3 AR 0.041
4 AR 0.041
5 AR 0.044
6 AR 0.051
7 AR 0.055
8 AR 0.058
9 AR 0.069
10 AR 0.076
11 HT-S 0.080
12 HT-S 0.084
13 HT-S 0.090
14 HT-S 0.091
15 HT-S 0.094
16 HT-S 0.096
17 GE 0.079
18 GE 0.086
19 GE 0.095
20 GE 0.104
21 GE 0.107
22 GE 0.118
23 GE 0.119
24 GE 0.137
25 GE 0.139
26 GE 0.152
27 GE 0.178
But it doesn't work well.
RM, best regards.
Marc Schwartz
<marc_schwartz at co
mcast.net> A
Romain.Mayor at ville-ge.ch
01.05.2007 19:49 cc
r-help at stat.math.ethz.ch
Objet
Veuillez répondre Re: [R] sorting in barplot
à
marc_schwartz at com
cast.net
On Tue, 2007-05-01 at 19:33 +0200, Romain.Mayor at ville-ge.ch wrote:
> Hello,
>
> I'm trying to sort my bargraph.CI plot (function like barplot in the
> SCIPLOT package) by the mean of the response variable.
>
> Does somebody have a trick for it.
>
> Thank you.
>
> Romain Mayor, PHD student.
If it is built on top of barplot(), then by default, the factor levels
of your response variable will determine the order of the bars in the
plot.
See ?reorder.factor for more details relative to defining the order
based upon the mean of the variable. There is an example there of using
the median.
HTH,
Marc Schwartz
More information about the R-help
mailing list