s-news
[Top] [All Lists]

Re: [S] SUMMARY: reference category in factors (was contr.treatment

To: V.Moreno@ico.scs.es
Subject: Re: [S] SUMMARY: reference category in factors (was contr.treatment
From: Prof Brian Ripley <ripley@stats.ox.ac.uk>
Date: Wed, 27 May 1998 13:29:38 +0100 (BST)
Cc: s-news@wubios.wustl.edu
Reply-to: Prof Brian Ripley <ripley@stats.ox.ac.uk>
Sender: owner-s-news@wubios.wustl.edu
I had a cut-and-paste error in my earlier posting:

relevel.factor <- function(x, ref, ...)
{
  lev <- levels(x); nlev <- length(lev)
  if(is.character(ref)) ref <- match(ref, lev)
  if(is.na(ref)) stop("ref must be an existing level")
# delete the next line
#  lev <- levels(x); nlev <- length(x)
  if(ref < 1 || ref > nlev) stop(paste("ref =", ref, "must be in 1 :", nlev))
  factor(x, levels = lev[c(ref, seq(along=lev)[-ref])] )
}

and the function I actually tested did not have that line in.
My apologies. Thanks to Jens Oehlschlaegel for pointing this out.

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-----------------------------------------------------------------------
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>