I have this table, and I want to reassign the case counts when the cause is C55. I want to redistribute it mathematically according to the proportion between C53 and C54 (that is, if both have 1, assign 50% of C55 to each). Always round down, and if there is any remaining whole number, assign it to C53. This should all be done separately for each age group.
# A tibble: 26 × 4
GENRE CAUSA GRUPEDAD CUENTA
<dbl> <chr> <chr> <dbl>
1 2 C55 55 a 59 1
2 2 C54 70 a 74 1
3 2 C54 80 y mas 1
4 2 C53 45 a 49 5
5 2 C54 60 a 64 1
6 2 C53 50 a 54 1
7 2 C53 80 y mas 2
8 2 C54 55 a 59 1
9 2 C53 65 a 69 3
10 2 C55 75 a 79 3
# ℹ 16 more rows