From Ted.Harding at manchester.ac.uk  Mon Aug  9 17:37:57 2010
From: Ted.Harding at manchester.ac.uk ( (Ted Harding))
Date: Mon, 09 Aug 2010 16:37:57 +0100 (BST)
Subject: [Rd] suggestion for ?factor
Message-ID: <XFMail.100809163757.Ted.Harding@manchester.ac.uk>

Hi Folks.
May I suggest a small addition to ?factor -- this is not explicit
about how to force the ordering of levels in an ordered factor.

One can guess it, but I think it would be a good idea to spell it out.
For example, one can do:

  X <- c("Alf","Bert","Chris","Dave")
  F <- factor(X,levels=c("Dave","Alf","Chris","Bert"),ordered=TRUE)
  F
  # [1] Alf   Bert  Chris Dave 
  # Levels: Dave < Alf < Chris < Bert

So, where ?factor says:

  levels: an optional vector of the values that ?x? might have taken.
          The default is the unique set of values taken by
          'as.character(x)', sorted into increasing order of 'x'.
          Note that this set can be smaller than 'sort(unique(x))'.

it could include a bit extra so as to read:

  levels: an optional vector of the values that 'x' might have taken.
          The default is the unique set of values taken by
          'as.character(x)', sorted into increasing order of 'x'.
          Note that this set can be smaller than 'sort(unique(x))'.
          If 'levels=...' is present and 'ordered=TRUE', then the
          levels are ordered according to the order in which they
          are listed in 'levels'.

With thanks,
Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 09-Aug-10                                       Time: 16:37:50
------------------------------ XFMail ------------------------------



[Rd] suggestion for ?factor
 (Ted Harding