Skip to content
Back to formatted view

Raw Message

Message-ID: <427B5A11.1020101@ucl.ac.uk>
Date: 2005-05-06T11:50:41Z
From: Gavin Simpson
Subject: Change class factor to numeric
In-Reply-To: <2395774549BBDA40AC83BC9E6223FBFF22F95F@MS-DT01VS01.tsn.tno.nl>

Smit, R. (Robin) (IenT) wrote:
> I am attempting to develop a multiple regression model using selected
> model variables that should all be treated as numeric (mostly real)
> values.
> However, R considers one specific variable "mass" automatically to be of
> class "factor", probably because "mass" consists of integer values that
> are repeated.
> I now want to force R to treat "mass" as a numeric variable in the
> regression but am not sure how to do this.
>  
> 
>>class(mass) <- "numeric"
> 
>  
> does not help me.
>  
> Could anyone advise me on this?

It is in the FAQ

7.10 How do I convert factors to numeric?

http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-do-I-convert-factors-to-numeric_003f

HTH

Gav
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Gavin Simpson                     [T] +44 (0)20 7679 5522
ENSIS Research Fellow             [F] +44 (0)20 7679 7565
ENSIS Ltd. & ECRC                 [E] gavin.simpsonATNOSPAMucl.ac.uk
UCL Department of Geography       [W] http://www.ucl.ac.uk/~ucfagls/cv/
26 Bedford Way                    [W] http://www.ucl.ac.uk/~ucfagls/
London.  WC1H 0AP.
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%