Hi,
How to order the levels os factor not by alphabetic order but by mean of Y.
Somethink like this:
I have this alphabetic order:
> levels(pH)
the order by mean os yvar is:
baixo medio alto
How to make the levels of pH ordered by this mean to the result to see
somethink like this:
> levels(pH)
I try this to make a function that I need to get ordered levels by this mean
and after rename to make a automatic contrasts by comparing models.
> levels(pH)[1] <- "baixomedio"
and after this a make a new model to be compared with a model with 3 levels
where "baixo" and "medio" is separated.
without ordered levels these command is wrong because the levels(pH)[1]
is "alto" and not "baixo".
Normally I use recode from car package, but for automatization your syntax is
a difficult.
Thanks
[1] "alto" "baixo" "medio"
> sort(tapply(Riqueza,pH,mean))
11.56667 20.00000 26.80000
[1] "baixo" "medio" "alto"
> levels(pH)[2] <- "baixomedio"
> levels(pH)
[1] "baixomedio" "alto"
Ronaldo
--
> Prof. Ronaldo Reis Júnior
| .''`. UNIMONTES/Depto. Biologia Geral/Lab. de Biologia Computacional
| : :' : Campus Universitário Prof. Darcy Ribeiro, Vila Mauricéia
| `. `'` CP: 126, CEP: 39401-089, Montes Claros - MG - Brasil
| `- Fone: (38) 3229-8187 | ronaldo.reis_at_unimontes.br | chrysopa_at_gmail.com
| http://www.ppgcb.unimontes.br/ | ICQ#: 5692561 | LinuxUser#: 205366
______________________________________________
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.
Received on Wed 20 Feb 2008 - 23:10:05 GMT
Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.
Archive generated by hypermail 2.2.0, at Thu 21 Feb 2008 - 02:30:16 GMT.
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.