I have a data frame with drug abuse information. Each row is a treatment episode that contains the STFIPS code for the state treatment occured in and a column with a 1 or a 0 indicating completion of treatment or failure to complete respectively.
STFIPS | OUTCOME |
---|---|
4 | 0 |
5 | 0 |
5 | 1 |
5 | 1 |
I am trying to find the percentage of 1's that occur for each state i.e. the percentage of completetion per each state (STFIPS) in the data frame. Ideally, this percent result would be in a seperate column...
Anybody got any ideas? Many thanks in advance!