Reputation: 13
I need to label a numeric variable, called sex, with "male" and "female". I was told to use de function "factor" but when I use it, it uses "1" and "2" instead of "0 " and "1". This is my code:
ucisex<−factor(ucisex<−factor(ucisex, levels = c(0:1), labels = c("male","female"))
It happens also with all the other variables when I label them. Please help!!!!
Mayra
Upvotes: 1
Views: 99
Reputation: 887391
The OP' had multiple <-
and factor
calls, which is not needed
ucisex <- factor(ucisex, levels = 0:1, labels = c("male", "female"))
ucisex
#[1] male male female female female female male female female male
#Levels: male female
set.seed(24)
ucisex <- sample(0:1, 10, replace=TRUE)
Upvotes: 0