Hi Guys
I Have 3 column, Merchant RGP, Facevalue, Status,
| Merchant RGP |
FaceValue |
Status |
| MAY & |
1500 |
Successful |
| MAY & |
1500 |
Failed |
| MAY & |
1500 |
Successful |
| Markers |
1500 |
Failed |
| Markers |
1500 |
Failed |
| Markers |
1500 |
Successful |
| Markers |
241 |
Failed |
| Bloosom |
1500 |
Failed |
| Bloosom |
1501 |
Failed |
| Flutters |
300 |
Successful |
| Flutters |
1000 |
Failed |
| Flutters |
200 |
Failed |
| Flutters |
2000 |
Successful |
| Flutters |
200 |
Successful |
| Flutters |
5100 |
Failed |
| Pecks |
100 |
Successful |
| Pecks |
200 |
Successful |
| Pecks |
500 |
Failed |
| Pecks |
300 |
Failed |
| Pecks |
100 |
Successful |
The Status column has been grouped into two observations eg successful and failed
in my code, I have grouped by the merchant RGP.
What I want is that I want to create or mutate and give me the sum of successful value for each merchant and also give me sum of failed value for each merchant
and create another column and give me the percentage of successful for each merchant and repeat the same for failed
but I didn't get the result
it keeps returning zeros for each merchant
you can help me add or edit my code and write a new one for me probably learn from it
here is my code
April_updated_new_stylea %>%
group_by(Merchant_RGP) %>%
summarise(Successful_rate = sum(Status == "Successful"),
failure_rate = sum(Status != "Successful" ))%>%
mutate(Successful_rate_pct = Successful_rate/sum(Successful_rate),
Failure_rate_pct = failure_rate/sum(failure_rate),
Success_Pct = round(Successful_rate_pct , digits = 2),
Failure_Pct = round(Failure_rate_pct, digits = 2)
Thank you