Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Msna indicators som #5

Merged
merged 10 commits into from
Oct 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.