Skip to content

Commit

Permalink
Merge pull request #5 from impact-initiatives-geospatial/msna_indicat…
Browse files Browse the repository at this point in the history
…ors_som

Msna indicators som
  • Loading branch information
twesigye10 authored Oct 27, 2022
2 parents 8e800ff + f87b9f7 commit db46a4e
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 11 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
.RData
.Ruserdata
/data/*
.xlsx*
*.xlsx
*.html
inst/doc
!/**/.gitkeep
49 changes: 46 additions & 3 deletions R/load_core_hh_indicators.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#' load_core_hh_indicators
#'
#' @param country_code
#' @param input_df The fetched data frame using the `fetch_msna` function
#' @param country_code The country code
#'
#' @return named list containing variable column names and labels

load_core_hh_indicators <- function(country_code="irq"){
load_core_hh_indicators <- function(input_df, country_code="irq"){
if (country_code=="irq"){
res <- list(
`Food Consumption Score (numeric)`= "fcs",
Expand All @@ -23,6 +24,42 @@ load_core_hh_indicators <- function(country_code="irq"){

}
if(country_code=="som"){
res <- list(
`Respondent Gender` = "respondent_gender",
`Respondent Age` = "respondent_age",
`Region` = "region",
`District` = "district",
`Reside in an IDP settlement` = "idp_settlement",
`Village/settlement/IDP site` = "settlements",
`Household Size` = "hh_size",
`Household's total cash income from all income sources` = "total_house_income",
`If yes, what is yoour household's current total amount of debt in USD` = "total_hh_debt",
`Drinking` = "drinking_water",
`Cooking` = "cooking_water",
`Personal hygiene (washing or bathing)` = "hygiene_water",
`Other domestic purposes (cleaning house, floor, etc.)` = "domestice_water",
`FSL shocks Unusually high food prices` = "hh_fsl_shocks/high_food_prices",
`FSL shocks Drought/irregular rains, prolonged dry spell` = "hh_fsl_shocks/drought",
`FSL shocks Unusually high level of crop pests and disease` = "hh_fsl_shocks/crop_disease",
`FSL shocks Disease outbreak in the settlement` = "hh_fsl_shocks/disease_outbreak",
`FSL shocks Too much rain, flooding` = "hh_fsl_shocks/flooding",
`FSL shocks Livestock disease outbreak` = "hh_fsl_shocks/livestock_disease",
`No food to eat of any kind in your house because of lack of resources to get food` = "hh_no_food",
`How often did this happen in the past [4 weeks/30 days]` = "hh_no_food_freq",
`Go to sleep at night hungry because there was not enough food` = "hh_hunger",
`How often did this happen in the past [4 weeks/30 days]` = "hh_hunger_freq",
`Go a whole day and night without eating anything at all because there was not enough food` = "fs_not_enough_food",
`Livestock decrease Disease outbreak` = "reason_livestock_decrease/disease_outbreak",
`Livestock decrease Flooding` = "reason_livestock_decrease/flooding_flooding",
`Livestock decrease Drought` = "reason_livestock_decrease/drought_drought",
`Recent displacement Flooding (riverine and flash flood)` = "factors_recent_displacement/flooding",
`Recent displacement Drought (lack of food, water, livestock loss)` = "factors_recent_displacement/drought",
`Recent displacement Desert locust invasion` = "factors_recent_displacement/desert_locust",
`Have access to your current shelter in the next 6 months` = "shelter_access",
`Latitude` = "Lat",
`Longitude` = "Lon",
`uuid` = "uuid"
)
}
if(country_code=="nga"){
res <- list(
Expand All @@ -31,7 +68,13 @@ load_core_hh_indicators <- function(country_code="irq"){
)

}
return(res)

# select the given columns on the fetched msna dataset
df_msna_cols <- input_df |>
select(any_of(purrr::map_chr(res, ~.x)), starts_with("rs_")) |>
mutate(country_code = country_code)

return(df_msna_cols)
}


10 changes: 8 additions & 2 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ You will need to decide on the variables in the HH data set that should be analy

```{r, eval =F}
load_core_hh_indicators <- function(country_code="irq"){
load_core_hh_indicators <- function(input_df, country_code="irq"){
if (country_code=="irq"){
res <- list(
# labels on left - column names on right
Expand All @@ -64,7 +64,13 @@ load_core_hh_indicators <- function(country_code="irq"){
)
}
return(res)
# select the given columns on the fetched msna dataset
df_msna_cols <- input_df |>
select(any_of(purrr::map_chr(res, ~.x))) |>
mutate(country_code = country_code)
return(df_msna_cols)
}
Expand Down
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ provided. If you have the same variables as another country make sure
you copy there label to use in your list.

``` r

load_core_hh_indicators <- function(country_code="irq"){
load_core_hh_indicators <- function(input_df, country_code="irq"){
if (country_code=="irq"){
res <- list(
# labels on left - column names on right
Expand All @@ -66,6 +65,12 @@ load_core_hh_indicators <- function(country_code="irq"){
)

}
return(res)

# select the given columns on the fetched msna dataset
df_msna_cols <- input_df |>
select(any_of(purrr::map_chr(res, ~.x))) |>
mutate(country_code = country_code)

return(df_msna_cols)
}
```
Empty file added data/.gitkeep
Empty file.
2 changes: 0 additions & 2 deletions vignettes/.gitignore

This file was deleted.

Binary file removed vignettes/corelation_checks.xlsx
Binary file not shown.

0 comments on commit db46a4e

Please sign in to comment.