s-news
[Top] [All Lists]

[S] Changing default ordering of factors

To: s-news@wubios.wustl.edu
Subject: [S] Changing default ordering of factors
From: "Gérald Jean" <Gerald.Jean@spgdag.ca>
Date: Tue, 27 Apr 1999 16:11:38 -0400
Sender: owner-s-news@wubios.wustl.edu
Hello everyone,

 I am a statistician working  in an actuarian group, I mostly develop GLM's
for them and they like to pick their own reference level in each factor
rather than having Splus pick it for them.  By default Splus will pick the
first level in the alphabetically sorted list of levels.  My question is
how do we change this default behaviour or if this is not possible how to
change the default ordering of factor levels.  I know how to do this
manually, but since I have a whole bunch to do with a lot of levels and
most likely I'll have to do it often I would like to have a function do it
for me.  Here is a little example of what I'd like to automate.

> ttt.age
[1] 19 20 30 30 19 20 20 19 19
> levels(ttt.age)
[1] "19" "30" "20"
> table(ttt.age)
 19 30 20
  4  2  3
> levels(ttt.age)_list('30'='30','20'='20','19'='19')
> levels(ttt.age)
[1] "30" "20" "19"
> table(ttt.age)
 30 20 19
  2  3  4
> ttt.age
[1] 19 20 30 30 19 20 20 19 19

ttt.age have not been changed, but now if it was an explanatory variable in
 a data.frame Splus would use level "30" as the reference
rather than the default level  "19".

Thanks for any suggestions, I'll summarize,

Gérald Jean
Analyste-conseil (statistiques), Actuariat
télephone            : (418) 835-8839
télecopieur          : (418) 835-5865
courrier électronique: gerald.jean@spgdag.ca

"In God we trust all others must bring data"


-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu.  To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message:  unsubscribe s-news

<Prev in Thread] Current Thread [Next in Thread>
  • [S] Changing default ordering of factors, G=E9rald_Jean <=