Hello, I´m stuck trying to summarize my data with some filters.
I have 3 differents filters:
Var_1 >1000,
Var_1 >500 & Var_1 <1000,
Var_1 <500
After filtering I want the percentage of another variable (Var_2) of each group over the total of Var_2.
Now I´m doing this. It has multiple steps and I know it is not the best way.
Hello. For future questions, please consider sharing a reproducible example (reprex) as described here. That makes it really easy for community members to help you.
For this question, I've prepared some sample data to illustrate one possible solution. To avoid duplication, you can use group_by() to perform the same operation across each of your three groups like so:
Thanks for your help. It´s almost solved but in the last step I need the percentage of the sum of each group of Var_1 (<500, <1000 >500, <1000) over the the total sum of Var_1.
Now is
summarize(Percentage = sum(Var_1) / sum(Var_2))
I don´t know how to invocate the sum of each group because obviusly if I write: