jeudi 21 janvier 2021

Translating IF condition from Excel to R

I have the following data

A B C D E
1 Date Temp.10 values Criteria
2 10/08/2020 1 0
3 11/08/2020 1 0
4 12/08/2020 1 0 0
5 13/08/2020 1 3 0
6 14/08/2020 1 13 0
7 15/08/2020 1 15 0
8 16/08/2020 1 7 1
9 17/08/2020 1 6 1
10 18/08/2020 1 0 1
11 19/08/2020 1 25 0

To meet the criteria (=1) the two previous days must have values higher than 5. In Excel I would just place my self in cell E4 and type:

=IF(AND(D3>5,D2>5),1,0)

And then pull down the formula.

I am trying to write this in R, but I am not succeeding!

Help much appreciated thank you :)

Aucun commentaire:

Enregistrer un commentaire