I have a large dataframe. As an example:
Week <- c(1, 1, 1, 2, 2, 2)
Outcome <- c( FALSE, FALSE , TRUE , TRUE, FALSE, FALSE)
df <- data.frame(Week, Outcome)
Week Outcome
1 1 FALSE
2 1 FALSE
3 1 TRUE
4 2 TRUE
5 2 FALSE
6 2 FALSE
In Outcome I would like to change FALSE to NA in case Outcome consists TRUE within the same Week.
So in this case the result will be:
Week Outcome
1 1 NA
2 1 NA
3 1 TRUE
4 2 TRUE
5 2 NA
6 2 NA
Thanks in advance for suggestions.