I have an order table that looks like this:
country_code other_info order_status
FR 1523 okay
FR 5151 not_okay
FR 41511 not_okay
IE 5151 okay
Both columns are of class character but even when transforming them into factors I got the same issue.
I just want to have the proportions of order_status grouped by country_code.
After running the following code I've got this error and I really cannot figure out what it means:
'Error in sum(count) : invalid 'type' (closure) of argument
library(dplyr)
orders %>%
group_by(country_code) %>%
mutate(countT= sum(count)) %>%
group_by(order_status, add=TRUE) %>%
mutate(per=paste0(round(100*count/countT,2),'%'))
What I want is this:
country_code order_status per
FR okay 33%
FR not_okay 66%
IE okay 100%
Thank you very much for your help, I'm sure it's something not complicated.