[R] String variables in GLM

Marcos_Sanches@gallup.com Marcos_Sanches at gallup.com
Tue Sep 11 18:04:09 CEST 2001


	Many thanks Thomas!!! The "factor" solved the problem!!!

Marcos


#-----Original Message-----
#From: Thomas Lumley [mailto:tlumley at u.washington.edu]
#Sent: Tuesday, September 11, 2001 12:29 PM
#To: Marcos_Sanches at gallup.com
#Cc: r-help at stat.math.ethz.ch
#Subject: Re: [R] String variables in GLM
#
#
#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
#eg
#
#  sex<-factor(sex,levels=c("Male","Female"))
#
#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).
#
#
#	-thomas
#
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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