in baseR, unless you attach or use a construct like within, you have to specificy where the variable you want comes from, like you did with SMWD$gender, but unlike when you referened 'Height' which to R just seems like some text that says Height in it. So either you rewrite your statement to
SMWD$RefEq <- ifelse(SMWD$gender =="male", (7.57*SMWD$Height) etc.
or switch to a dplyr syntax ( install.packages("dplyr") as a one time first step)
SMWD <- SMWD %>% mutate(RefEq =
ifelse(gender =="male",
(7.57*Height)-(5.02*Age)-(1.76*Weight)-309,
(2.11*Height)-(2.29*Weight)-(5.78*Age)+667)
)
inside of a dplyr mutate, its generally clear where the variable mentioned should come from ( the data.frame that mutate is operating on)
More info here:
https://r4ds.had.co.nz/