NA in multiple criteria dummy formula

Help! I spent hours creating this formula and can't get over the last hurdle.

The dummy formula needs to look at 3 criteria: time period, working hours and salaries. The only variable with NA is Wrk_Hrs.

The issue is the dummy formula (High01) is allocating a value for some NA working hours but not all. It ignored the observations that are linked to the last variable condition - Salary.

My issues is, I don't know how to allocate 0 for NA hours and salaries between 12877.5 and 33177.

The formula I'm using:
df$High01 <- ifelse(df$Year == 1 & df$Wrk_Hrs >= 30 & df$Salary >= 33177
| df$Year == 1 & df$Wrk_Hrs < 30 & df$Salary >= 12877.5
| df$Year == 1 & is.na(df$Wrk_Hrs) & df$Salary >= 33177, "1", "0")

Sample of the output
image

This is the first time I'm posting. I hope I have included all the information needed to provide some solutions suggestions.

Thank you.

Hi, welcome to the forum.

I think we need a FAQ: How to do a minimal reproducible example ( reprex ) for beginners

A handy way to supply some sample data is the dput() function. In the case of a large dataset something like dput(head(mydata, 100)) should supply the data we need.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.