Commit 8fa4d433 authored by Simon, Wolfram's avatar Simon, Wolfram
Browse files

The FertNutr sheet was combined with the FRV sheet. The HumanNutrSheet was...

The FertNutr sheet was combined with the FRV sheet. The HumanNutrSheet was updated. A function was added to read cifos model data easily.
parent 636307bc
......@@ -35,6 +35,15 @@ FUNload_list_monfreda <- function(path, type) {
return(l_csv)
}
# Loading Model data from local repository
Fun_ModelData = function(sheet){
library("readxl")
if (Sys.getenv("USERNAME") == "wacke003") {
dir_mapping = "C:/Users/wacke003/Git/wolfram/Input_data/Mappings/"
} else {
dir_mapping = "D:/GAMS/EU_model_Feb2022/"
}
read_excel(paste0(dir_mapping,"European_CiFoS_model_data.xlsx"), sheet = sheet) }
# Crop variable conversion ------------------------------------------------
# Calculate production from yields and area - here: suitable yields
......
......@@ -8,6 +8,11 @@ easypackages::packages("odbc","DBI", "RSQLite", "dbplyr", "readxl", "fuzzyjoin",
"sqldf", "downloader", "tidyverse", "janitor", "FAOSTAT",
"validate")
# Source functions ------------------------------------------------------
source("Functions_cifos/function_collection.R")
# https://www.youtube.com/watch?v=CydajdNRJOU -----------------------------
# con <- dbConnect(odbc::odbc(),
......@@ -2005,7 +2010,7 @@ read_csv("Input_data/animal_nutrition_all.csv")
# 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) %>%
rename(product = Prod)
dplyr::rename(product = Prod)
loss_values = read_csv("Input_data/gusatvsson_loss_table.csv") %>%
rename(Fam_Gustavson = `...1`)
......@@ -2749,3 +2754,31 @@ write_csv(dat_dist, "Input_data/dat_dist.csv")
# Consistenc check - After meeting Thomas 01.03.22 ------------------------
# Problem: Main products that are not in human food nutr
Processing_Fraction = Fun_ModelData("Processing_Fraction")
HumNutr_sheet = Fun_ModelData("Human_Food_Nutr")
# All main products in processing sheet
main = Processing_Fraction %>% filter(utilization == "MainProduct")
# All values of processing sheet that are not in human nutrition sheet
main$proc_out[!main$proc_out %in% HumNutr_sheet$Product]
# "cocoa_powder_cake" "soyabean_feed_oil"
# FertNutr ----------------------------------------------------------------
# Issue: remove the ASF products from FertNutr
# Loading fertnutr
FertNutr = Fun_ModelData("FertNutr")
# Getting the ASF products from loss fraction
dat_lossfrac = read_excel("Input_data/Copy of European_CiFoS_model_data_ANITANov21.xlsx", sheet = "Loss_Fraction_New")
asf_procraw_vec = dat_lossfrac %>% dplyr::select(c(1:10)) %>% janitor::row_to_names(1)%>% select(-ProdCat ,-Fam_SPAM) %>%
dplyr::rename(product = Prod) %>%
filter(Fam_Gustavson %in% c("Meat", 'Fish & seafood', "Milk", "Eggs")) %>%
distinct(product) %>% pull()
FertNutr = FertNutr %>% filter(!Product %in% asf_procraw_vec) %>% as_tibble() %>%
type.convert() %>% write_csv("Input_data/FertNutr_update_3_22.csv")
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