I have a data set with seven inputs.  Four of which are categorical.  For my
midterm, my professor wants us to scale all the inputs.  This means, I
pressume, that I have to use 'recode' or 'factor' to transform the
categorical data in numerical.  For example, one input variable is
'race=(b,w,h,o)'.  I just want to assign a numerical value to all
'b,w,h,o'.  I thought 'recode' should do this, but it doesn't work.  Here's
the code I'm using for recode:

recode(race, "b='1';w='2';h='3';o='4'")

this is the error I get:
Error in eval(expr, envir, enclos) : object "o" not found


It's not that there's no "o".  If I change the order or combination of the
variables, it always can't find one of them.

I could also use 'factor', from what I hear.  But, I looked at the help
section on this function and I ended up more confused.


How do I code it so these variables take on numerial values?  I need to be
able to use:

race.centered = race - mean(race)


This scaling code doesn't really make sense if the values of 'race' are
non-numerical.  I might end up dividing by 2 SD's as well.  But, I don't
know if I need to.  I'll have to do some more reading.


Thank you for your help!

        [[alternative HTML version deleted]]

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to