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?