I have tried to do this a couple different ways with medium success, but now have a final form I want to do this and am not sure how. I have a df that I want to add a column to with values of 0 and 1 depending on how two other columns compare in that row.
I don't have any code set on how to do this, but what I am trying to do is compare PTS to dPTS and add a column beyond dPTS called W/L.
IF PTS>dPTS put a 1 in the column
IF PTS,dPTS put a 0 in the column
Not a very good reprex at all, but wasn't quite sure how to explain. I check this a lot and will reply quickly to any questions on stuff that's not clear.
ID | Home | Team | Mins | oMins | dMins | oPOSS | dPOSS | ORTG | DRTG | NETRTG | PTS | dPTS | FGA | dFGA |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
UCLA | 0 | Seattle U | 39 | 20 | 19 | 72 | 72 | 72 | 108 | -36 | 52 | 78 | 59 | 51 |
Long Beach St. | 0 | Seattle U | 38 | 22 | 17 | 76 | 77 | 99 | 104 | -5 | 75 | 80 | 64 | 59 |
Washington | 0 | Seattle U | 39 | 21 | 18 | 68 | 69 | 60 | 106 | -46 | 41 | 73 | 59 | 56 |
Northwest (WA) | 1 | Seattle U | 39 | 16 | 23 | 70 | 69 | 127 | 58 | 69 | 89 | 40 | 59 | 58 |
Col. of Idaho | 1 | Seattle U | 39 | 19 | 20 | 68 | 70 | 115 | 77 | 38 | 78 | 54 | 63 | 53 |
California | 0 | Seattle U | 39 | 20 | 19 | 63 | 64 | 103 | 109 | -6 | 65 | 70 | 60 | 53 |
Portland | 1 | Seattle U | 40 | 21 | 19 | 79 | 76 | 106 | 89 | 17 | 84 | 68 | 68 | 64 |
Saint Martin's | 1 | Seattle U | 39 | 18 | 21 | 74 | 73 | 132 | 86 | 46 | 98 | 63 | 60 | 69 |
Utah Valley | 1 | Seattle U | 44 | 23 | 21 | 92 | 90 | 100 | 103 | -3 | 92 | 93 | 73 | 57 |
Dixie St. | 0 | Seattle U | 40 | 21 | 19 | 75 | 73 | 101 | 105 | -4 | 76 | 77 | 71 | 64 |
Dixie St. | 0 | Seattle U | 39 | 22 | 18 | 78 | 76 | 99 | 74 | 25 | 77 | 56 | 57 | 57 |