I am new to R. I have a categorical variable that I like to make a linear model and do prediction with it but RStudio does not let me do so unless I change the type of the variable.
How can I change the yes/no to 1/0?
my error is
" variable 'medal' is not a factor"
I have tried :
> sport$medal <- factor(sport$medal)
If you want to replace the yes/no with 1/0 use the ifelse()
sport$medal <- ifelse(sport$medal == "yes", 1, 0)