Re: [R] Change class factor to numeric

From: Gavin Simpson <gavin.simpson_at_ucl.ac.uk>
Date: Fri 06 May 2005 - 21:50:41 EST

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.
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Fri May 06 21:58:00 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:37 EST