jeudi 4 juin 2020

How to identify certain change in pattern using r

I have a dataset with daily measures of the same blood level for the same subjects. all patients are "positive" to begin with, most change to negative at some point. some remain negative till the end of the experiment while others turn positive after negative.

I am trying to identify those who turn positive after negative.

Tried ifelse and tried lag function in dplyr but could not get anywhere.

here is an example of how my data looks like:

subject      day1      day2      day3      day4      day5      day6      day7
1       A positive  positive  positive  positive  positive  positive  positive 
2       B positive  positive   negative positive   negative  negative  negative
3       C positive  positive  positive   negative  negative positive  positive 
4       D positive  positive  positive   negative  negative  negative  negative

Aucun commentaire:

Enregistrer un commentaire