Skip to content
Back to formatted view

Raw Message

Message-ID: <003701c13adb$640543c0$b454a8c0@gallup.com.br>
Date: 2001-09-11T16:04:09Z
From: Marcos_Sanches@gallup.com
Subject: String variables in GLM
In-Reply-To: <Pine.A41.4.33.0109110825360.62078-100000@homer16.u.washington.edu>

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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._