My data is as follows:
The UID is an individual's random ID number, the collection date is the date on which the test was drawn, and the result is, naturally, the result of the test. UID and result are factors, collection_date is a date.
What I'm trying to do is filter to rows where someone changes from a negative to a positive test result. Ex of the data - how would I filter to the two rows with 5, and do this for many such pairings?:
example <- cbind(UID = c(1,2,3,4,rep(5,2),6),COLLDT = sample(seq(as.Date('1999/01/01'), as.Date('2000/01/01'), by="day"), 7), RESULT = c("P","P","P","P","N","P","P")