Homework: Answer mismatch

If I want to remove -1 and NA from variable 'lbtme' in dataframe 'labor22p_s', this will be the code, right?

labor22p_s$lbtme <- ifelse(labor22p_s$lbtme != -1, labor22p_s$lbtme, NA)

labor22p_s <- labor22p_s %>% filter(!is.na(lbtme))


and I was trying to extract only 1 and 2 from variable 'regular' in dataframe 'labor22p_s'.

labor22p_s <- labor22p_s %>% filter(regular == 1 | regular == 2)


and the task I was trying to do is to find the average of the 'lbtme'
from the observations which have 1 in 'regular'.

labor22p_s %>% filter(regular == 1) %>%
summarise(mean(lbtme))


This is one of the school assignment and the correct answer is already given. I thought I did okay in this but apparently my codes showing me the wrong answer. Is there anything wrong in my code?

There is nothing evidently wrong with your code, to help us help you, could you please prepare a reproducible example (reprex) illustrating your issue? Please have a look at this guide, to see how to create one:

If there is nothing wrong in the code, then it is just error in the assignment! I sent him a message, I just wanted to make sure if I'm doing something wrong here since I'm merely a beginner. Thank you so much! Have a good day!

That is not what I meant, there is no evident error but since you are not sharing your data I can't test it to be sure, there is always the possibility that your code is not suitable for your data because it is in a format that requires preprocessing or some other reason I'm not considering. That is why I was asking for a reproducible example.