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
bc321bd2
Commit
bc321bd2
authored
Feb 11, 2022
by
Wacker, Jan-David
Browse files
sdsdz
parent
613c892c
Changes
1
Hide whitespace changes
Inline
Side-by-side
R_to_SQL_database/Cifos_Model_Data_EU.R
View file @
bc321bd2
...
...
@@ -3042,17 +3042,24 @@ write_csv(animal_map, "Input_Data/diets_animal_crop_datamap.csv")
# Distance matrix ---------------------------------------------------------
# Data is taken from here: https://github.com/mlschneid/country-distance/blob/master/output/distance-matrix.csv
dat_distance
=
read_csv
(
"Input_data/Distance_matrix.csv"
)
%>%
rename
(
"CountryA"
=
"...1"
)
dat_distance
=
read_csv
(
"Input_data/Distance_matrix.csv"
)
#
%>%
#
rename("CountryA" = "...1")
# Country map for subsetting EU
country_map_FAO_iso2
=
read.csv
(
here
::
here
(
"Input_data"
,
"Mappings"
,
"dat_map_SPAM_GAUL_CIFOS_FAO.csv"
))
%>%
as_tibble
()
%>%
dplyr
::
select
(
iso3_SPAM
,
iso2_code_FAO
,
name_cntr_CIFOS2021
)
country_map_FAO_iso2
=
read.csv
(
"Input_data/Mappings/dat_map_SPAM_GAUL_CIFOS_FAO.csv"
)
%>%
drop_na
()
%>%
as_tibble
()
%>%
dplyr
::
select
(
iso3_SPAM
,
iso2_code_FAO
,
name_cntr_CIFOS2021
)
%>%
mutate
(
iso3_SPAM
=
as.character
(
iso3_SPAM
))
%>%
add_column
(
a
=
numeric
(
nrow
(
country_map_FAO_iso2
)))
# EU28 - Subsetting -------------------------------------------------------
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"
)
for
(
i
in
1
:
nrow
(
country_map_FAO_iso2
)){
if
(
country_map_FAO_iso2
[
i
,
"iso3_SPAM"
]
%in%
EU_iso3
){
country_map_FAO_iso2
[
i
,
"a"
]
=
1
}
}
dat_distance
%>%
pivot_longer
()
...
...
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