Skip to content
Back to formatted view

Raw Message

Message-ID: <Pine.LNX.4.44.0306041352260.4793-100000@gannet.stats>
Date: 2003-06-04T12:55:03Z
From: Brian Ripley
Subject: convert factor to numeric
In-Reply-To: <20030604120446.GA5875@porcupine.gsf.de>

See the FAQ, Q7.12.

On Wed, 4 Jun 2003, Philipp Pagel wrote:

> Every once in a while I need to convert a factor to a vector of numeric
> values. as.numeric(myfactor) of course returns a nice numeric vector of
> the indexes of the levels which is usually not what I had in mind:
...

It's done that way because that is how it is defined to work in S, and 
lots of code relies on it.

-- 
Brian D. Ripley,                  ripley at 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 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595