So in my data.frame "whr2021", I have a variable called "Social support" that is the national average of the binary responses (either 0 or 1) to the question “If you were in trouble, do you have relatives or friends you can count on to help you whenever you need them, or not?”. So this variable takes decimal values between 0 and 1.
I would like to have it is a factor() value so it is easier to analyse it. I would like it to take the value "no" if the value is under 0.5 and "yes" if it is over or equal to 0.5. So basically something like that (but this doesn't work so please correct me):
The reason why it's not working is your levels vector. c(<0.5, >=0.5) simply produces an error, since you aren't comparing anything inside c() with your relational signs. But if you instead check the condition within an ifelse() statement beforehand and initialize the factor on the new chr vector, it will work like you can see above.