[R] Change class factor to numeric
Gavin Simpson
gavin.simpson at ucl.ac.uk
Fri May 6 13:50:41 CEST 2005
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.
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
More information about the R-help
mailing list