First and foremost, thank you for taking your time to view my question.
My question is regarding a flag that I am trying to create: Essentially the flag works like this: - If the value of column vals is greater than 3 for 3 consecutive days, I want the original value to be flagged. I am trying to use an ifelse statement, however, I just don't know how to code the "stays greater than 3 for 3 consecutive days" in R. I have tried for multiple hours without no solution :/
The sample data might looks something like this
Date Vals
8/1/11 2.5
8/2/11 2.6
8/3/11 1.6
8/4/11 3.6
8/5/11 3.5
8/6/11 3.1
8/7/11 3.8
8/8/11 2.1
8/9/11 1.6
8/10/11 3.1
So essentially: I would get a third column called FLAG that would only list error on 8/4/11 and 8/5/11 column and NO ERROR on the rest.
Please let me know, and thank you for your time!
Aucun commentaire:
Enregistrer un commentaire