Hi,
I'm new to R programming and taking an online course to learn more. I've come across a problem that I can understand and was wondering if anyone can point me in the right direction and explain what I did wrong.
I'm trying to categorize my data variable hdl based on gender and hdl levels. I enter the code below
gender<-mydata$gender
hdlcat<-ifelse(gender="male" & hdl<40, "at risk",
ifelse(gender="male" & hdl>=40, "desirable",
ifelse(gender="female" & hdl<50, "at risk",
ifelse(gender="female" & hdl>=50, "desirable", NA))))
When I run the code I'm getting this error message:
hdlcat<-ifelse(gender="male" & hdl<40, "at risk",
-
ifelse(gender="male" & hdl>=40, "desirable",
-
ifelse(gender="female" & hdl<50, "at risk",
-
ifelse(gender="female" & hdl>=50, "desirable", NA)))))
Error in ifelse(gender = "male" & hdl < 40, "at risk", ifelse(gender = "male" & :
unused argument (gender = "male" & hdl < 40)
I don't quite understand this "unused argument (gender = "male" & hdl < 40)" and honestly I've tried random things to just get the code to work, but not understanding what I'm doing wrong?
Any help is appreciated