Commit 2f9f7916 authored by Simon, Wolfram's avatar Simon, Wolfram
Browse files

Updated the grassland and function file

parent 43d16f2d
......@@ -59,7 +59,7 @@ Fun_aggregate = function(suitability_dat){
dplyr::select(ADM0_CODE, AEZ, Soil_agri, tech_type, crops, SAR_ha, SPR_ton) %>%
dplyr::group_by(ADM0_CODE, AEZ, Soil_agri, tech_type, crops) %>%
dplyr::summarise(SAR_ha = sum(SAR_ha),
SPR_ton = sum(SPR_ton))
SPR_ton = sum( ))
}
......@@ -347,13 +347,13 @@ grass_EU28 %>% group_by(iso3_SPAM, stock_rate) %>%
# Bar chart filtered for the current stockingrate 10
grass_EU28 %>% group_by(iso3_SPAM, stock_rate) %>%
dplyr::filter(stock_rate %in% c(10)) %>%
# dplyr::summarise(yield_DM_kgha_mean = mean(yield_DM_kgha, na.rm = TRUE))%>%
dplyr::summarise(
yield_DM_kgha_mean = weighted.mean(x=yield_DM_kgha, w = area_ha, #weighted mean
yield_DM_kgha[!is.na(yield_DM_kgha) & yield_DM_kgha != 0])) %>%
dplyr::filter(stock_rate %in% c(20)) %>%
# dplyr::summarise(yield_DM_kgha_mean = mean(yield_DM_kgha, na.rm = TRUE))%>%
# dplyr::summarise(
# yield_DM_kgha_mean = weighted.mean(x=yield_DM_kgha, w = area_ha, #weighted mean
# yield_DM_kgha[!is.na(yield_DM_kgha) & yield_DM_kgha != 0])) %>%
ggplot(aes(y=yield_DM_kgha_mean,x=reorder(iso3_SPAM, -yield_DM_kgha_mean), fill=stock_rate))+
ggplot(aes(y=yield_DM_kgha ,x=reorder(iso3_SPAM, -yield_DM_kgha ), fill=stock_rate))+
geom_bar(stat = "identity", position = "dodge", alpha = 0.7)+
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust = 1))+
scale_fill_viridis_d()+
......@@ -420,11 +420,12 @@ grass_EU28 %>% group_by(iso3_SPAM ) %>%
# Fresh weight
FM_yields_EU = grass_EU28 %>%
group_by(iso3_SPAM,stock_rate, lut_cifos) %>%
dplyr::summarise(yield_FM_kgha =
weighted.mean(x=yield_FM_kgha,
# dplyr::summarise(yield_FM_kgha=mean(yield_FM_kgha)) %>%
dplyr::summarise(yield_FM_kgha =
weighted.mean(x=yield_FM_kgha,
w = area_ha, #weighted mean
yield_FM_kgha[!is.na(yield_FM_kgha) &
yield_FM_kgha != 0])) %>%
yield_FM_kgha != 0])) %>%
dplyr::mutate(yield_FM_kgha=replace_na(yield_FM_kgha,0))
FM_yields_EU %>%
......
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