Commit a7df76d4 authored by Simon, Wolfram's avatar Simon, Wolfram
Browse files

deleted weired headers

parent a76eba84
Loading packages --------------------------------------------------------
# Loading packages --------------------------------------------------------
# Loading the packages
# .libPaths("C:/Wolfram_Admin/R-4.1.2/R-4.1.2/library")
# install.packages("easypackages", dependencies = T)
# library("easypackages")
# Loading packages
easypackages::packages("odbc","DBI", "RSQLite", "dbplyr", "readxl", "fuzzyjoin",
<<<<<<< HEAD
"sqldf", "downloader", "tidyverse", "janitor", "FAOSTAT",
=======
"sqldf", "downloader", "tidyverse", "janitor", "FAOSTAT",
>>>>>>> bdd608029dd5899a8a1a0b93359f2d957d331ba1
"validate")
# https://www.youtube.com/watch?v=CydajdNRJOU -----------------------------
......@@ -247,7 +244,7 @@ dat_crop_final = read_csv("Input_data/dat_crop_with_grass_final.csv") %>%
# Adding the grass to the old crop name columns so it will not result in NA later.
dplyr::mutate(old_cifos_crop = case_when(is.na(old_cifos_crop) ~ crop_cifos,
TRUE ~ old_cifos_crop))
# Fuzzy join of processing sheet and the crop map
# crop_map_cifos_procraw =
dat_proc = Processing_sheet %>%
......@@ -508,11 +505,7 @@ proc_new = tibble("crop_cifos" = NA, "proc_raw" = NA, "proc_in" = NA, "proc_out"
add_row(crop_cifos = "cassava" , proc_raw = "cassava" , proc_in = "cassava_tapiocain", proc_out = "cassava_tapioca", value = 0.2, dietary_products = "Cassava and products") %>%
add_row(crop_cifos = "cassava" , proc_raw = "cassava" , proc_in = "cassava_dryin", proc_out = "cassava_dry", value = 0.35, dietary_products = "Cassava and products") %>%
add_row(crop_cifos = "cassava" , proc_raw = "cassava" , proc_in = "cassava_starchin", proc_out = "cassava_starch", value = 0.25, dietary_products = "Cassava and products") %>%
<<<<<<< HEAD
=======
>>>>>>> bdd608029dd5899a8a1a0b93359f2d957d331ba1
# Pearl millet -- Source: from Technical Conversion Factors for Agricultural Commodities (http://countrystat.org/resources/documents/tcf.pdf); adjusted commodity tree; fractions from "cereals/millet"
# levels: only one level
add_row(crop_cifos = "pearl_millet" , proc_raw = "pearl_millet" , proc_in = "pearl_millet_flourin", proc_out = "pearl_millet_flour", value = 0.86, dietary_products = "Millet and products") %>%
......@@ -870,21 +863,6 @@ dat_proc_asf =
clean_names() %>% rename(proc_raw = pro_raw) %>%
slice(269:363) %>%
dplyr::mutate(dietary_products= case_when(proc_raw == "Milk" ~ "Milk - Excluding Butter",
<<<<<<< HEAD
TRUE ~ dietary_products),
dietary_products= case_when(proc_out == "Butter" ~ "Butter, Ghee",
TRUE ~ dietary_products),
dietary_products= case_when(dietary_products == "Fish (Calculated CiFoS)" ~ "Fish, Seafood",
TRUE ~ dietary_products),
proc_out = case_when(proc_out == "Butter_Milk" ~ "Butter_milk",
TRUE ~ proc_out)) #this was written with a uppercase here and a lower case in the food losses sheet
Processing_sheet_final = bind_rows(dat_proc_new %>% dplyr::select(-crop_cifos),dat_proc_asf)
write_csv(Processing_sheet_final, "Input_data/processing_sheet.csv")
=======
TRUE ~ dietary_products),
dietary_products= case_when(proc_out == "Butter" ~ "Butter, Ghee",
TRUE ~ dietary_products),
......@@ -898,7 +876,6 @@ write_csv(Processing_sheet_final, "Input_data/processing_sheet.csv")
Processing_sheet_final = bind_rows(dat_proc_new %>% dplyr::select(-crop_cifos),dat_proc_asf)
write_csv(Processing_sheet_final, "Input_data/processing_sheet.csv")
>>>>>>> bdd608029dd5899a8a1a0b93359f2d957d331ba1
# Human nutrition sheet ---------------------------------------------------
# Human nutrtion sheet
......@@ -1007,11 +984,7 @@ hum_nutr_all = bind_rows(food_old_match, food_psf_new, food_asf)
# check = full_join(hum_nutr_all, proc_new, by = c("product"="proc_out"))
write_csv(hum_nutr_all, "Input_data/hum_nutr_all.csv")
<<<<<<< HEAD
=======
>>>>>>> bdd608029dd5899a8a1a0b93359f2d957d331ba1
# Animal nutrition new ----------------------------------------------------
# Cifos sheet
......@@ -2159,11 +2132,7 @@ crop_other_new =
distinct_at(vars(crop_cifos),.keep_all = T) %>% drop_na(crop_cifos)
write_csv(crop_other_new, "Input_Data/crop_other_new.csv")
<<<<<<< HEAD
=======
>>>>>>> bdd608029dd5899a8a1a0b93359f2d957d331ba1
# cropnutr = read_excel('C:/Wolfram_Admin/GAMS/EU_model_frmSep21/cifos-model_eu/European_CiFoS_model_data.xlsx',sheet="CropNutr")
# write_csv(cropnutr,"Input_data/cropnutr_old")
cropnutr = read_csv("Input_data/cropnutr_old")
......@@ -2174,13 +2143,8 @@ cropnutr_new =
full_join(crop_map %>% dplyr::select(old_cifos_crop, crop_cifos), by = c("crop_cifos_old"="old_cifos_crop")) %>%
relocate(crop_cifos, .before = crop_cifos_old) %>%
dplyr::select(-crop_cifos_old)
<<<<<<< HEAD
write_csv(cropnutr_new, "Input_data/cropnutr_new.csv")
=======
write_csv(cropnutr_new, "Input_data/cropnutr_new.csv")
>>>>>>> bdd608029dd5899a8a1a0b93359f2d957d331ba1
# CropFert_New NOT DONE! ------------------------------------------------------------
# CropFert_New = read_excel("C:/Wolfram_Admin/GAMS/EU_model_frmSep21/cifos-model_eu/European_CiFoS_model_data.xlsx", sheet = "CropFert_New")
......@@ -2311,7 +2275,6 @@ write_csv(animal_map, "Input_Data/diets_animal_crop_datamap.csv")
# # Animals
# #Animal_yield sheet
# 1. Yields (column D row 2)
<<<<<<< HEAD
......@@ -2323,5 +2286,3 @@ write_csv(animal_map, "Input_Data/diets_animal_crop_datamap.csv")
=======
>>>>>>> bdd608029dd5899a8a1a0b93359f2d957d331ba1
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment