Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Simon, Wolfram
CiFoS_Crops
Commits
3080113f
Commit
3080113f
authored
Mar 04, 2022
by
Wacker, Jan-David
Browse files
Added function for creating mapping table between ISO3 and CiFoS country names
parent
8fa4d433
Changes
1
Hide whitespace changes
Inline
Side-by-side
Functions_cifos/function_collection.R
View file @
3080113f
...
...
@@ -37,13 +37,43 @@ FUNload_list_monfreda <- function(path, type) {
# Loading Model data from local repository
Fun_ModelData
=
function
(
sheet
){
# loads CiFoS model input data
# INPUT:
# - sheet: string with name of sheet to be read
# OUTPUT:
# - dataframe with sheet content
library
(
"readxl"
)
if
(
Sys.getenv
(
"USERNAME"
)
==
"wacke003"
)
{
dir
=
"C:/Users/wacke003/Git/cifos-model.eu/"
}
else
{
dir
=
"D:/GAMS/EU_model_Feb2022/"
}
return
(
read_excel
(
paste0
(
dir
,
"European_CiFoS_model_data.xlsx"
),
sheet
=
sheet
))
}
# Loading table with country name mapping
Fun_CountryMapping
=
function
(){
# loads a table with the mapping of ISO3 country names and respective country
# names used in the CiFoS model.
# OUTPUT:
# - tibble with country name mapping
library
(
"readxl"
)
EU_iso3
=
c
(
"AUT"
,
"BEL"
,
"BGR"
,
"HRV"
,
"CZE"
,
"DNK"
,
"EST"
,
"FIN"
,
"FRA"
,
"DEU"
,
"GRC"
,
"HUN"
,
"IRL"
,
"ITA"
,
"LVA"
,
"LTU"
,
"LUX"
,
"MLT"
,
"NLD"
,
"POL"
,
"PRT"
,
"ROU"
,
"SVK"
,
"SVN"
,
"ESP"
,
"SWE"
,
"GBR"
,
"CYP"
)
if
(
Sys.getenv
(
"USERNAME"
)
==
"wacke003"
)
{
dir_mapping
=
"C:/Users/wacke003/Git/wolfram/Input_data/Mappings/"
}
else
{
dir_mapping
=
"
D
:/
GAMS/EU_model_Feb2022
/"
dir_mapping
=
"
C
:/
Users/simon083/OneDrive - Wageningen University & Research/PhD_WJS/Academic/RQ1/Data_analysis/Spatial_mod/Modified_scripts/R/CifoS_Crop/Input_data/Mappings
/"
}
read_excel
(
paste0
(
dir_mapping
,
"European_CiFoS_model_data.xlsx"
),
sheet
=
sheet
)
}
dat_map_SPAM_GAUL_CIFOS_FAO
=
read.csv
(
paste
(
dir_mapping
,
"dat_map_SPAM_GAUL_CIFOS_FAO.csv"
,
sep
=
""
))
%>%
as_tibble
()
%>%
dplyr
::
select
(
iso3_SPAM
,
name_cntr_CIFOS2021
)
%>%
filter
(
iso3_SPAM
%in%
EU_iso3
)
return
(
dat_map_SPAM_GAUL_CIFOS_FAO
)
}
# Crop variable conversion ------------------------------------------------
# Calculate production from yields and area - here: suitable yields
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment