View source: R/ExtractNewValues.R
extract_new_core_units | R Documentation |
A function to extract the new values from a core RHoMIS survey. Note that this function will not work on any dataset which has modified the core questions.
extract_new_core_units(data)
data |
The RHoMIS core dataset for which we are hoping to extract the new values |
Rpackage file: ExtractNewValues.R
A nested list of all of the unique values for core RHoMIS values
data <- tibble::tibble(
crop_name_1 = c("maize", "cassava"),
crop_name_2 = c(NA, "cucumber"),
random_crop_name_2 = c("blue", "green"),
livestock_name_1 = c("cow", "chicken"),
livestock_name_2 = c("pig", NA),
crop_yield_units_1 = c("kg", "sacks"),
crop_yield_units_2 = c("wheelbarrow", NA),
crop_yield_units_other_1 = c("other1", NA),
crop_yield_units_other_2 = c("other2", "other3"),
crop_sold_price_quantityunits_1 = c(NA, "price1"),
crop_sold_price_quantityunits_2 = c("price2", "price3"),
crop_price_quantityunits_other_1 = c(NA, "crop_price_1"),
crop_price_quantityunits_other_2 = c(NA, "crop_price_2"),
crop_price_quantityunits_other_3 = c(NA, "crop_price_3"),
crop_price_quantityunits_other_4 = c(NA, NA),
unitland = c("acre", NA),
areaunits_other = c("area1", "area2"),
unitland_owned = c("unitland1", "unitland2"),
unitland_rentin = c("renty1", "renty2"),
unitland_rentout = c("rent1", "rent5"),
milk_units_1 = c("milk1", NA),
milk_units_2 = c("milk4", "milk5"),
milk_amount_units_other_1 = c("milkoth1", "milkoth2"),
milk_amount_units_other_2 = c(NA, "milkoth3"),
milk_sold_price_timeunits_1 = c("mspt1", "mspt3"),
milk_sold_price_timeunits_2 = c(NA, "mspt5"),
milk_amount_time_units_other_1 = c("mspto1", NA),
milk_amount_time_units_other_2 = c("mspto2", "mspto3"),
bees_honey_production_units_1 = c("hnyprod1", "hnyprod2"),
bees_honey_production_units_2 = c(NA, "hnyprod3"),
bees_honey_production_units_other_1 = c("hnyprodoth1", NA),
bees_honey_production_units_other_2 = c("hnyprodoth2", "hnyprodoth3"),
eggs_units_1 = c("egg1", NA),
eggs_units_2 = c("egg2", "egg3"),
eggs_amount_units_other_1 = c("eggoth1", NA),
eggs_amount_units_other_2 = c("eggoth2", "eggoth3"),
eggs_sold_price_timeunits_1 = c("eggtime1", "eggtime2"),
eggs_sold_price_timeunits_2 = c("eggtime3", NA),
eggs_sold_price_timeunits_3 = c(NA, NA),
eggs_sold_price_timeunits_other_1 = c("eggtimeoth1", NA),
eggs_sold_price_timeunits_other_2 = c("eggtimeoth2", "eggtimeoth3"),
fertiliser_units = c("fert1", "fert2"),
fertiliser_units_other = c("fertoth1", "fertoth2")
)
result <- extract_new_core_units(data)
expected_result <- c(list(
"crop_name" = c(
"maize",
"cassava",
"cucumber"
),
"livestock_name" = c(
"cow",
"chicken",
"pig"
),
"crop_yield_units" = c(
"kg",
"sacks",
"wheelbarrow",
"other1",
"other2",
"other3"
),
"crop_sold_price_quantityunits" = c(
"price1",
"price2",
"price3",
"crop_price_1",
"crop_price_2",
"crop_price_3"
),
"unitland" = c(
"acre",
"hectare",
"m2",
"area1",
"area2",
"area3",
"unitland1",
"unitland2",
"unitland3",
"renty1",
"renty2",
"renty3",
"rent1",
"rent2",
"rent5"
),
"milk_units" = c(
"milk1",
"milk4",
"milk5",
"milkoth1",
"milkoth2",
"milkoth3"
),
"milk_sold_price_timeunits" = c(
"mspt1",
"mspt3",
"mspt5",
"mspto1",
"mspto2",
"mspto3"
),
"bees_honey_production_units" = c(
"hnyprod1",
"hnyprod2",
"hnyprod3",
"hnyprodoth1",
"hnyprodoth2",
"hnyprodoth3"
),
"eggs_units" = c(
"egg1",
"egg2",
"egg3",
"eggoth1",
"eggoth2",
"eggoth3"
),
"eggs_sold_price_timeunits" = c(
"eggtime1",
"eggtime2",
"eggtime3",
"eggtimeoth1",
"eggtimeoth2",
"eggtimeoth3"
),
"fertiliser_units" = c(
"fert1",
"fert2",
"fertoth1",
"fertoth2"
)
))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.