I am trying to code the following
I have 240 rows and 11 columns. I want to do the following: If the value in (row 1, column 1) was greater than 0 and if the value in (row 1, column 2) was greater than 0, then count the value in (row 1, column 4).
For an example: (row,column)
If (1,1) = (1) AND if (1,2)=(1) then count the value in (1,4)
If (2,1) = (1) AND if (2,2)=(0) then DO NOT COUNT the value in (2,4)
If (3,1) = (0) AND if (3,2)=(1) then DO NOT COUNT the value in (3,4)
etc...
I have already seen a quite similar post, however there was only 1 condition given instead of 2.
I tried the following solution, which did not work sum(DataFrame_a[DataFrame_a[ ,1] > 0, DataFrame_a[ ,2] > 0, 4])
Thank you in advance for your help.
Aucun commentaire:
Enregistrer un commentaire