2
I would like to create a nominal variable X
(factor) in my data.frame
from two other existing nominal variables Renda
and Escolaridade
:
Renda Escolaridade X
baixa fund. incomp Sim
inter superior Nao
alta pos grad Nao
alta medio Nao
So when Renda = "baixa"
and Escolaridade = "fund. incomp"
var. X
will receive the label= "Sim"
and all other combinations will receive label="Nao"
I tried to use the function ifelse
, but it seems to me that it applies to var. numeric
only.
Thank you, Rafael. It was going wrong, because I inserted only one = instead of ==
– Naomi
in R a = is the same as <- for the equality test, you have to use ==
– Rafael Cunha