@@ -686,9 +686,9 @@ module_xfaostat_L107_FoodBalanceSheet <- function(command, ...) {
686
686
687
687
688
688
689
- # Section6 Connect food items and macronutrient rates ----
689
+ # Section3 Connect food items and macronutrient rates ----
690
690
691
- # 6 .1 Separate FAO food items into GCAM food items and NEC for macronutrient ----
691
+ # 3 .1 Separate FAO food items into GCAM food items and NEC for macronutrient ----
692
692
# GCAM included most of the food items
693
693
# All food item with available macronutrient info from FAOSTAT are included
694
694
@@ -724,7 +724,7 @@ module_xfaostat_L107_FoodBalanceSheet <- function(command, ...) {
724
724
SUA_Items_Food
725
725
726
726
727
- # 6 .2 Get macronutrient values ----
727
+ # 3 .2 Get macronutrient values ----
728
728
729
729
# ## a. Get world average macronutrient ----
730
730
# For filling in missing values
@@ -781,7 +781,38 @@ module_xfaostat_L107_FoodBalanceSheet <- function(command, ...) {
781
781
select(- macronutrient )- >
782
782
L107.Traceable_FBS_Food_Calorie_Macronutrient_2010Plus
783
783
784
+ # Potential discrepancy in food calorie and macronutrient aggregation (due to data quality)
785
+ # when the processing use of primary is zero while there is indeed secondary output and food consumption
786
+ # food in secondary products won't be converted to primary due to zero extraction rates.
787
+ # fortunately, there are only a few cases in small areas/sectors.
788
+ # One example is "Other citrus and products" in PCe in "bra"
784
789
790
+ L107.Traceable_FBS_Food_Calorie_Macronutrient_2010Plus %> %
791
+ group_by(area_code , year , APE_comm_Agg , element ) %> %
792
+ summarize(value = sum(value ), .groups = " drop" ) %> %
793
+ # anti join ones with positive food mass in PCe
794
+ anti_join(
795
+ L107.Traceable_FBS_PCe_2010Plus %> %
796
+ filter(element == " Food" , value > 0 ) %> %
797
+ spread(element , value ) %> % rename(area_code = region_ID ),
798
+ by = c(" area_code" , " year" , " APE_comm_Agg" )
799
+ ) %> %
800
+ # check remaining positive
801
+ filter(value > 0 ) %> %
802
+ distinct(area_code , year , APE_comm_Agg ) %> %
803
+ mutate(ZeroFood = 0 ) - >
804
+ FBS_FOOD_SCALER
805
+
806
+ # After checks above, there were 30 obs; we change the calorie and macronutrient to zero in FBS
807
+ L107.Traceable_FBS_Food_Calorie_Macronutrient_2010Plus %> %
808
+ left_join(FBS_FOOD_SCALER ,
809
+ by = c(" area_code" , " year" , " APE_comm_Agg" )) %> %
810
+ mutate(value = if_else(is.na(ZeroFood ), value , value * 0 )) %> %
811
+ select(- ZeroFood ) - >
812
+ L107.Traceable_FBS_Food_Calorie_Macronutrient_2010Plus
813
+
814
+
815
+ # # Done Section3 ----
785
816
# ****************************----
786
817
# Produce outputs ----
787
818
0 commit comments