[R] String variables in GLM

Thomas Lumley tlumley at u.washington.edu
Tue Sep 11 17:28:44 CEST 2001

On Tue, 11 Sep 2001 Marcos_Sanches at gallup.com wrote:

> 	Hello!
> 	I have a dataset with variables in string format (ages class and sex) which
> I want to recode as numerical variables. How can I accomplish this?  Is
> there any way to do that automatically? Could someone help me?

You probably want factor variables. These are described in Section 4 of
the 'Introduction to R' manual.

Reading variables in using read.table will typically make them into
factors automatically. If you have string variables use factor() to
convert them


The variable can then be used in regression modelling where it will by
default be coded with indicator variables for each level except the first
(in this case that corresponds to Male=0, Female=1).


r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list