Function to aggregate data according to different scenario
Arguments
- df5W
fame with response tracking data
- lookup_dfindicator
fame with indicator look up
- proportions
can be "pin" or "target" - this uses configuration available within the spreadsheet inst/Proportions.xlsx
- totalmodel
can be either: * "sum": sums all beneficiaries of all sectors to get intersector figures per admin1 level and then at national level
* "maxsector" : sums all beneficiaries at sector and admin1 level, then take the max of each age and gender categories for each population type to get the intersector figure
* "southernconemodel" : Mixed approach in 3 steps:
1. Max across Shelter, Food security, Humanitarian transport and WASH
2. Take Protection (General) data
3. Sum Other sectors mentionned: Integration, Multipurporse CBI, Health, Education
Examples
lookup_dfindicator <- fct_read_lookup(type = "indicator")
df5W <- fct_read_data()
## Check all 6 combinations...
### Combination 1
resultpinsum <- fct_aggregate_data(df5W,
lookup_dfindicator,
proportions = "pin",
totalmodel = "sum"
)
head(resultpinsum, 10)
#> # A tibble: 10 × 23
#> Platform Country Admin1 Month Subsector Monthly Total Benefi…¹
#> <chr> <chr> <chr> <chr> <chr> <dbl>
#> 1 Southern Cone Argentina Buenos Aires 2023-01 Education 0
#> 2 Southern Cone Argentina Buenos Aires 2023-01 Food Sec… 0
#> 3 Southern Cone Argentina Buenos Aires 2023-01 Health 0
#> 4 Southern Cone Argentina Buenos Aires 2023-01 Humanita… 0
#> 5 Southern Cone Argentina Buenos Aires 2023-01 Integrat… 28
#> 6 Southern Cone Argentina Buenos Aires 2023-01 Multipur… 33
#> 7 Southern Cone Argentina Buenos Aires 2023-01 Nutrition 0
#> 8 Southern Cone Argentina Buenos Aires 2023-01 Protecti… 0
#> 9 Southern Cone Argentina Buenos Aires 2023-01 Protecti… 0
#> 10 Southern Cone Argentina Buenos Aires 2023-01 Protecti… 0
#> # ℹ abbreviated name: ¹`Monthly Total Beneficiaries`
#> # ℹ 17 more variables: `Monthly CVA Beneficiaries` <dbl>,
#> # `Consolidated Total` <dbl>, `Consolidated In Destination` <dbl>,
#> # `Consolidated In Transit` <dbl>, `Consolidated Host Communities` <dbl>,
#> # `Consolidated Pendular` <dbl>, `Consolidated Returnees` <dbl>,
#> # `Consolidated Girls` <dbl>, `Consolidated Boys` <dbl>,
#> # `Consolidated Women` <dbl>, `Consolidated Men` <dbl>, …
### Combination 2
resulttargetsum <- fct_aggregate_data(df5W,
lookup_dfindicator,
proportions = "target",
totalmodel = "sum"
)
head(resulttargetsum, 10)
#> # A tibble: 10 × 23
#> Platform Country Admin1 Month Subsector Monthly Total Benefi…¹
#> <chr> <chr> <chr> <chr> <chr> <dbl>
#> 1 Southern Cone Argentina Buenos Aires 2023-01 Education 0
#> 2 Southern Cone Argentina Buenos Aires 2023-01 Food Sec… 0
#> 3 Southern Cone Argentina Buenos Aires 2023-01 Health 0
#> 4 Southern Cone Argentina Buenos Aires 2023-01 Humanita… 0
#> 5 Southern Cone Argentina Buenos Aires 2023-01 Integrat… 28
#> 6 Southern Cone Argentina Buenos Aires 2023-01 Multipur… 33
#> 7 Southern Cone Argentina Buenos Aires 2023-01 Nutrition 0
#> 8 Southern Cone Argentina Buenos Aires 2023-01 Protecti… 0
#> 9 Southern Cone Argentina Buenos Aires 2023-01 Protecti… 0
#> 10 Southern Cone Argentina Buenos Aires 2023-01 Protecti… 0
#> # ℹ abbreviated name: ¹`Monthly Total Beneficiaries`
#> # ℹ 17 more variables: `Monthly CVA Beneficiaries` <dbl>,
#> # `Consolidated Total` <dbl>, `Consolidated In Destination` <dbl>,
#> # `Consolidated In Transit` <dbl>, `Consolidated Host Communities` <dbl>,
#> # `Consolidated Pendular` <dbl>, `Consolidated Returnees` <dbl>,
#> # `Consolidated Girls` <dbl>, `Consolidated Boys` <dbl>,
#> # `Consolidated Women` <dbl>, `Consolidated Men` <dbl>, …
### Combination 3
resultpinmaxsector <- fct_aggregate_data(df5W,
lookup_dfindicator,
proportions = "pin",
totalmodel = "maxsector"
)
head(resultpinmaxsector, 10)
#> # A tibble: 10 × 23
#> Platform Country Admin1 Month Subsector Monthly Total Benefi…¹
#> <chr> <chr> <chr> <chr> <chr> <dbl>
#> 1 Southern Cone Argentina Buenos Aires 2023-01 Education 0
#> 2 Southern Cone Argentina Buenos Aires 2023-01 Food Sec… 0
#> 3 Southern Cone Argentina Buenos Aires 2023-01 Health 0
#> 4 Southern Cone Argentina Buenos Aires 2023-01 Humanita… 0
#> 5 Southern Cone Argentina Buenos Aires 2023-01 Integrat… 28
#> 6 Southern Cone Argentina Buenos Aires 2023-01 Multipur… 33
#> 7 Southern Cone Argentina Buenos Aires 2023-01 Nutrition 0
#> 8 Southern Cone Argentina Buenos Aires 2023-01 Protecti… 0
#> 9 Southern Cone Argentina Buenos Aires 2023-01 Protecti… 0
#> 10 Southern Cone Argentina Buenos Aires 2023-01 Protecti… 0
#> # ℹ abbreviated name: ¹`Monthly Total Beneficiaries`
#> # ℹ 17 more variables: `Monthly CVA Beneficiaries` <dbl>,
#> # `Consolidated Total` <dbl>, `Consolidated In Destination` <dbl>,
#> # `Consolidated In Transit` <dbl>, `Consolidated Host Communities` <dbl>,
#> # `Consolidated Pendular` <dbl>, `Consolidated Returnees` <dbl>,
#> # `Consolidated Girls` <dbl>, `Consolidated Boys` <dbl>,
#> # `Consolidated Women` <dbl>, `Consolidated Men` <dbl>, …
### Combination 4
resulttargetmaxsector<- fct_aggregate_data(df5W,
lookup_dfindicator,
proportions = "target",
totalmodel = "maxsector"
)
head(resulttargetmaxsector, 10)
#> # A tibble: 10 × 23
#> Platform Country Admin1 Month Subsector Monthly Total Benefi…¹
#> <chr> <chr> <chr> <chr> <chr> <dbl>
#> 1 Southern Cone Argentina Buenos Aires 2023-01 Education 0
#> 2 Southern Cone Argentina Buenos Aires 2023-01 Food Sec… 0
#> 3 Southern Cone Argentina Buenos Aires 2023-01 Health 0
#> 4 Southern Cone Argentina Buenos Aires 2023-01 Humanita… 0
#> 5 Southern Cone Argentina Buenos Aires 2023-01 Integrat… 28
#> 6 Southern Cone Argentina Buenos Aires 2023-01 Multipur… 33
#> 7 Southern Cone Argentina Buenos Aires 2023-01 Nutrition 0
#> 8 Southern Cone Argentina Buenos Aires 2023-01 Protecti… 0
#> 9 Southern Cone Argentina Buenos Aires 2023-01 Protecti… 0
#> 10 Southern Cone Argentina Buenos Aires 2023-01 Protecti… 0
#> # ℹ abbreviated name: ¹`Monthly Total Beneficiaries`
#> # ℹ 17 more variables: `Monthly CVA Beneficiaries` <dbl>,
#> # `Consolidated Total` <dbl>, `Consolidated In Destination` <dbl>,
#> # `Consolidated In Transit` <dbl>, `Consolidated Host Communities` <dbl>,
#> # `Consolidated Pendular` <dbl>, `Consolidated Returnees` <dbl>,
#> # `Consolidated Girls` <dbl>, `Consolidated Boys` <dbl>,
#> # `Consolidated Women` <dbl>, `Consolidated Men` <dbl>, …
### Combination 5
resultpinsouthernconemodel <- fct_aggregate_data(df5W,
lookup_dfindicator,
proportions = "pin",
totalmodel = "southernconemodel"
)
head(resultpinsouthernconemodel, 10)
#> # A tibble: 10 × 23
#> Platform Country Admin1 Month Subsector Monthly Total Benefi…¹
#> <chr> <chr> <chr> <chr> <chr> <dbl>
#> 1 Southern Cone Argentina Buenos Aires 2023-01 Education 0
#> 2 Southern Cone Argentina Buenos Aires 2023-01 Food Sec… 0
#> 3 Southern Cone Argentina Buenos Aires 2023-01 Health 0
#> 4 Southern Cone Argentina Buenos Aires 2023-01 Humanita… 0
#> 5 Southern Cone Argentina Buenos Aires 2023-01 Integrat… 28
#> 6 Southern Cone Argentina Buenos Aires 2023-01 Multipur… 33
#> 7 Southern Cone Argentina Buenos Aires 2023-01 Nutrition 0
#> 8 Southern Cone Argentina Buenos Aires 2023-01 Protecti… 0
#> 9 Southern Cone Argentina Buenos Aires 2023-01 Protecti… 0
#> 10 Southern Cone Argentina Buenos Aires 2023-01 Protecti… 0
#> # ℹ abbreviated name: ¹`Monthly Total Beneficiaries`
#> # ℹ 17 more variables: `Monthly CVA Beneficiaries` <dbl>,
#> # `Consolidated Total` <dbl>, `Consolidated In Destination` <dbl>,
#> # `Consolidated In Transit` <dbl>, `Consolidated Host Communities` <dbl>,
#> # `Consolidated Pendular` <dbl>, `Consolidated Returnees` <dbl>,
#> # `Consolidated Girls` <dbl>, `Consolidated Boys` <dbl>,
#> # `Consolidated Women` <dbl>, `Consolidated Men` <dbl>, …
### Combination 6
resulttargetsouthernconemodel <- fct_aggregate_data(df5W,
lookup_dfindicator,
proportions = "target",
totalmodel = "southernconemodel"
)
head(resulttargetsouthernconemodel, 10)
#> # A tibble: 10 × 23
#> Platform Country Admin1 Month Subsector Monthly Total Benefi…¹
#> <chr> <chr> <chr> <chr> <chr> <dbl>
#> 1 Southern Cone Argentina Buenos Aires 2023-01 Education 0
#> 2 Southern Cone Argentina Buenos Aires 2023-01 Food Sec… 0
#> 3 Southern Cone Argentina Buenos Aires 2023-01 Health 0
#> 4 Southern Cone Argentina Buenos Aires 2023-01 Humanita… 0
#> 5 Southern Cone Argentina Buenos Aires 2023-01 Integrat… 28
#> 6 Southern Cone Argentina Buenos Aires 2023-01 Multipur… 33
#> 7 Southern Cone Argentina Buenos Aires 2023-01 Nutrition 0
#> 8 Southern Cone Argentina Buenos Aires 2023-01 Protecti… 0
#> 9 Southern Cone Argentina Buenos Aires 2023-01 Protecti… 0
#> 10 Southern Cone Argentina Buenos Aires 2023-01 Protecti… 0
#> # ℹ abbreviated name: ¹`Monthly Total Beneficiaries`
#> # ℹ 17 more variables: `Monthly CVA Beneficiaries` <dbl>,
#> # `Consolidated Total` <dbl>, `Consolidated In Destination` <dbl>,
#> # `Consolidated In Transit` <dbl>, `Consolidated Host Communities` <dbl>,
#> # `Consolidated Pendular` <dbl>, `Consolidated Returnees` <dbl>,
#> # `Consolidated Girls` <dbl>, `Consolidated Boys` <dbl>,
#> # `Consolidated Women` <dbl>, `Consolidated Men` <dbl>, …