Commit 08fac85c authored by Simon, Wolfram's avatar Simon, Wolfram
Browse files

Included the animalfeednutr sheet based on demis sheet. Refers to issue #42...

Included the animalfeednutr sheet  based on demis sheet. Refers to issue #42 Animal nutrition sheet in the Cifos-Model EU remote repos
parent 3080113f
# Loading packages --------------------------------------------------------
# Loading the packages
# .libPaths("C:/Wolfram_Admin/R-4.1.2/R-4.1.2/library")
# install.packages("easypackages", dependencies = T)
# install.packages("rlang")
# library("easypackages")
# Loading packages
easypackages::packages("odbc","DBI", "RSQLite", "dbplyr", "readxl", "fuzzyjoin",
......@@ -835,8 +837,7 @@ proc_new = tibble("crop_cifos" = NA, "proc_raw" = NA, "proc_in" = NA, "proc_out"
# Treenuts
add_row(crop_cifos = "treenuts" , proc_raw = "walnuts" , proc_in = "walnuts", proc_out = "walnuts", value = 0.5, dietary_products = "Nuts and products") %>%
add_row(crop_cifos = "treenuts" , proc_raw = "walnuts" , proc_in = "walnuts", proc_out = "nut_shell", value = 0.5, dietary_products = "Nuts and products")
# Consistency check processing --------------------------------------------
# Check if there is a duplicate proc_in - proc_out combination
duplicated(proc_new[,3:4]) #not
......@@ -1113,6 +1114,10 @@ hum_nutr_all_FG = hum_nutr_all %>% dplyr::select(-FoodGroup) %>%
# check = full_join(hum_nutr_all, proc_new, by = c("product"="proc_out"))
write_csv(hum_nutr_all_FG, "Input_data/hum_nutr_all.csv")
# Animal nutrition new ----------------------------------------------------
# Cifos sheet
dat_animnutr = readxl::read_excel("Input_data/Copy of European_CiFoS_model_data_ANITANov21.xlsx", sheet = "Animal_Nutr")
......@@ -2007,6 +2012,38 @@ ani_nutr_v7.2.22=animal_nutrition_all_old %>% dplyr::select(c(product)) %>%
write_csv(animal_nutrition_all, "Input_data/animal_nutrition_all.csv")
read_csv("Input_data/animal_nutrition_all.csv")
}
# Update and check demis animal nutrition sheet 11.03.2022 ------------------------------------------
AnimSheetDemi = read_excel("D:/GAMS/EU_model_Feb2022/European_CiFoS_model_data.xlsx", sheet = "AnimSheetDemi")
Animal_Feed_Nutr_old= read_excel("D:/GAMS/EU_model_Feb2022/European_CiFoS_model_data.xlsx", sheet = "Animal_Feed_Nutr" )
# Reference sheet
Animal_Feed_Nutr_old
# Fixing the number of columns
AnimSheetDemi2 = AnimSheetDemi %>% select(-c( CFATh...63 ,NFEh...64)) %>%
relocate(K, .before = "VEM") %>%
type.convert() %>%
mutate_at(vars(FIC, OccurrenceIncMort, MortalityHerdType,
MortalityProducer, DurationHerdType, DurationProducer),
~"")
# Consistency check: are all the products in the old in the new
# All values of animal nutritiondemi that are not in old sheet
AnimSheetDemi2$Product[!AnimSheetDemi2$Product %in% Animal_Feed_Nutr_old$Product]
# All values of animal nutritiondemi that are not in old sheet
vec_missing = Animal_Feed_Nutr_old$Product[!Animal_Feed_Nutr_old$Product %in% AnimSheetDemi2$Product]
miss = vec_missing %>% as_tibble() %>% rename(Product = value)
# Addding the missing Products to be filled with values
AnimSheetDemi_comp = AnimSheetDemi2 %>% bind_rows(miss)
# Are the values distinct?
# Loss fraction sheet ----------------------------------------------------
dat_lossfrac = read_excel("Input_data/Copy of European_CiFoS_model_data_ANITANov21.xlsx", sheet = "Loss_Fraction_New")
dat_lossfrac_join= dat_lossfrac %>% dplyr::select(c(1:10)) %>% janitor::row_to_names(1)%>% select(-ProdCat ,-Fam_SPAM) %>%
......
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