As the global population has grown and become wealthier, there has been a rapid surge in the need for food, energy, and water. The demand for all three not only has risen, but they are also closely interconnected: the production of food relies on both water and energy, conventional energy production necessitates water resources, and agriculture offers a potential source of energy. This analysis centers on examining the environmental consequences of food. This document presents an analysis of the environmental impact of various food products, based on their greenhouse gas emissions during production. The aim is to identify food products with high emissions and analyze the contribution of different stages of food production to overall emissions.
The dataset includes information on various food products and their associated greenhouse gas emissions at different stages of production, such as land use change, farming, processing, transport, packaging, and retail. This comprehensive dataset allows for a detailed analysis of the carbon footprint associated with each food product.
I seek to answer the following questions: 1. What are the total emissions by food product? 2. Which types of food have a more significant negative impact on the environment? 3. Which stage of food production contributes the most to greenhouse gas emissions? 4. How do plant-based and animal-based foods compare in terms of their carbon footprint? 5. How does food distribution by emissions happen in top 2 phases (which most contributes in the greenhouse gas emissions)? 6. What are the relationship among food production phases?
library(data.table)
library(readr)
library(ggplot2)
library(RColorBrewer)
library(ggthemes)
library(reshape2)
##
## Attaching package: 'reshape2'
## The following objects are masked from 'package:data.table':
##
## dcast, melt
# Load the data
food_emission <- readr::read_csv('https://raw.githubusercontent.com/thimaipham/Data/main/Food_Production.csv')
## Rows: 43 Columns: 23
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): Food product
## dbl (22): Land use change, Animal Feed, Farm, Processing, Transport, Packgin...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
# Convert to data table and check the structure
setDT(food_emission)
head(food_emission)
## Food product Land use change Animal Feed Farm Processing Transport
## 1: Wheat & Rye (Bread) 0.1 0 0.8 0.2 0.1
## 2: Maize (Meal) 0.3 0 0.5 0.1 0.1
## 3: Barley (Beer) 0.0 0 0.2 0.1 0.0
## 4: Oatmeal 0.0 0 1.4 0.0 0.1
## 5: Rice 0.0 0 3.6 0.1 0.1
## 6: Potatoes 0.0 0 0.2 0.0 0.1
## Packging Retail Total_emissions
## 1: 0.1 0.1 1.4
## 2: 0.1 0.0 1.1
## 3: 0.5 0.3 1.1
## 4: 0.1 0.0 1.6
## 5: 0.1 0.1 4.0
## 6: 0.0 0.0 0.3
## Eutrophying emissions per 1000kcal (gPO₄eq per 1000kcal)
## 1: NA
## 2: NA
## 3: NA
## 4: 4.281357
## 5: 9.514379
## 6: 4.754098
## Eutrophying emissions per kilogram (gPO₄eq per kilogram)
## 1: NA
## 2: NA
## 3: NA
## 4: 11.23
## 5: 35.07
## 6: 3.48
## Eutrophying emissions per 100g protein (gPO₄eq per 100 grams protein)
## 1: NA
## 2: NA
## 3: NA
## 4: 8.638462
## 5: 49.394366
## 6: 20.470588
## Freshwater withdrawals per 1000kcal (liters per 1000kcal)
## 1: NA
## 2: NA
## 3: NA
## 4: 183.9116
## 5: 609.9837
## 6: 80.7377
## Freshwater withdrawals per 100g protein (liters per 100g protein)
## 1: NA
## 2: NA
## 3: NA
## 4: 371.0769
## 5: 3166.7606
## 6: 347.6471
## Freshwater withdrawals per kilogram (liters per kilogram)
## 1: NA
## 2: NA
## 3: NA
## 4: 482.4
## 5: 2248.4
## 6: 59.1
## Greenhouse gas emissions per 1000kcal (kgCO₂eq per 1000kcal)
## 1: NA
## 2: NA
## 3: NA
## 4: 0.9454823
## 5: 1.2072708
## 6: 0.6284153
## Greenhouse gas emissions per 100g protein (kgCO₂eq per 100g protein)
## 1: NA
## 2: NA
## 3: NA
## 4: 1.907692
## 5: 6.267606
## 6: 2.705882
## Land use per 1000kcal (m² per 1000kcal)
## 1: NA
## 2: NA
## 3: NA
## 4: 2.897446
## 5: 0.759631
## 6: 1.202186
## Land use per kilogram (m² per kilogram)
## 1: NA
## 2: NA
## 3: NA
## 4: 7.60
## 5: 2.80
## 6: 0.88
## Land use per 100g protein (m² per 100g protein)
## 1: NA
## 2: NA
## 3: NA
## 4: 5.846154
## 5: 3.943662
## 6: 5.176471
## Scarcity-weighted water use per kilogram (liters per kilogram)
## 1: NA
## 2: NA
## 3: NA
## 4: 18786.2
## 5: 49576.3
## 6: 2754.2
## Scarcity-weighted water use per 100g protein (liters per 100g protein)
## 1: NA
## 2: NA
## 3: NA
## 4: 14450.92
## 5: 69825.77
## 6: 16201.18
## Scarcity-weighted water use per 1000kcal (liters per 1000 kilocalories)
## 1: NA
## 2: NA
## 3: NA
## 4: 7162.104
## 5: 13449.891
## 6: 3762.568
This dataset contains most 43 most common foods grown across the globe and 23 columns as their respective land, water usage and carbon footprints.
Some key columns:
These represent greenhouse gas emissions per kg of food product(Kg CO2 - equivalents per kg product) across different stages in the lifecycle of food production.
missing_percentage <- colSums(is.na(food_emission)) / nrow(food_emission) * 100
print(missing_percentage)
## Food product
## 0.00000
## Land use change
## 0.00000
## Animal Feed
## 0.00000
## Farm
## 0.00000
## Processing
## 0.00000
## Transport
## 0.00000
## Packging
## 0.00000
## Retail
## 0.00000
## Total_emissions
## 0.00000
## Eutrophying emissions per 1000kcal (gPO₄eq per 1000kcal)
## 23.25581
## Eutrophying emissions per kilogram (gPO₄eq per kilogram)
## 11.62791
## Eutrophying emissions per 100g protein (gPO₄eq per 100 grams protein)
## 37.20930
## Freshwater withdrawals per 1000kcal (liters per 1000kcal)
## 30.23256
## Freshwater withdrawals per 100g protein (liters per 100g protein)
## 39.53488
## Freshwater withdrawals per kilogram (liters per kilogram)
## 11.62791
## Greenhouse gas emissions per 1000kcal (kgCO₂eq per 1000kcal)
## 23.25581
## Greenhouse gas emissions per 100g protein (kgCO₂eq per 100g protein)
## 37.20930
## Land use per 1000kcal (m² per 1000kcal)
## 23.25581
## Land use per kilogram (m² per kilogram)
## 11.62791
## Land use per 100g protein (m² per 100g protein)
## 37.20930
## Scarcity-weighted water use per kilogram (liters per kilogram)
## 11.62791
## Scarcity-weighted water use per 100g protein (liters per 100g protein)
## 39.53488
## Scarcity-weighted water use per 1000kcal (liters per 1000 kilocalories)
## 30.23256
The results indicate that from the Food product to Total emissions variables, no missing values are observed. However, the remaining variables exhibit a substantial percentage of missing values, ranging from 11 to 40 percent. In light of this, and considering the absence of sufficient information and domain knowledge, I have decided to exclude these variables from the analytical scope, as they won’t contribute to the analysis at hand.
# Delete unnecessary columns in the analytics
total_emissions_index <- which(names(food_emission) == "Total_emissions")
food_emission[, (total_emissions_index+1):ncol(food_emission) := NULL]
In this section of the analysis, I focus on preparing the dataset for visual representation. The preparation involves several key steps, each aimed at extracting meaningful insights from the food_emission dataset: 1. Calculate the average emissions across all food products to identify those with emissions higher than the average. 2. Delve into analyzing the total emissions from each production phase by transforming the dataset from a wide to a long format, enabling us to conduct detailed analyses on each stage. 3. categorize products into two groups: plant-based and animal-based, based on the animal feed, to explore their environmental impact more distinctly.
Through these steps, I lay the groundwork for deeper visualization and analysis of the environmental effects of food production.
# The average of the 'Total_emissions' column across the entire data.table
average_emissions <- food_emission[, mean(Total_emissions)]
print(average_emissions)
## [1] 5.972093
# Filter products are greater than the average emissions
high_emission_products <- food_emission[Total_emissions > average_emissions]
print(high_emission_products)
## Food product Land use change Animal Feed Farm Processing Transport
## 1: Soybean Oil 3.1 0.0 1.5 0.3 0.3
## 2: Palm Oil 3.1 0.0 2.1 1.3 0.2
## 3: Olive Oil -0.4 0.0 4.3 0.7 0.5
## 4: Coffee 3.7 0.0 10.4 0.6 0.1
## 5: Dark Chocolate 14.3 0.0 3.7 0.2 0.1
## 6: Beef (beef herd) 16.3 1.9 39.4 1.3 0.3
## 7: Beef (dairy herd) 0.9 2.5 15.7 1.1 0.4
## 8: Lamb & Mutton 0.5 2.4 19.5 1.1 0.5
## 9: Pig Meat 1.5 2.9 1.7 0.3 0.3
## 10: Poultry Meat 2.5 1.8 0.7 0.4 0.3
## 11: Cheese 4.5 2.3 13.1 0.7 0.1
## 12: Shrimps (farmed) 0.2 2.5 8.4 0.0 0.2
## Packging Retail Total_emissions
## 1: 0.8 0.0 6.0
## 2: 0.9 0.0 7.6
## 3: 0.9 0.0 6.0
## 4: 1.6 0.1 16.5
## 5: 0.4 0.0 18.7
## 6: 0.2 0.2 59.6
## 7: 0.3 0.2 21.1
## 8: 0.3 0.2 24.5
## 9: 0.3 0.2 7.2
## 10: 0.2 0.2 6.1
## 11: 0.2 0.3 21.2
## 12: 0.3 0.2 11.8
# Total emission for each phase of food producing:
emissions_summary <- melt(food_emission,
measure.vars = c("Land use change", "Animal Feed", "Farm", "Processing", "Transport", "Packging", "Retail"),
variable.name = "Production_Stage",
value.name = "Total_Emissions")
emissions_summary <- as.data.table(emissions_summary)
# Total emission by Production_Stage
emissions_summary <- emissions_summary[, .(Total_Emissions = sum(Total_Emissions)), by = .(Production_Stage)]
emissions_summary <- emissions_summary[order(Total_Emissions)] #order the result by ascending
print(emissions_summary)
## Production_Stage Total_Emissions
## 1: Retail 3.0
## 2: Transport 8.4
## 3: Processing 10.9
## 4: Packging 11.6
## 5: Animal Feed 19.5
## 6: Land use change 54.2
## 7: Farm 149.2
# Filter animal-based foods (Animal Feed > 0.0) and plant-based foods
# Then create a new column called Food_Type
food_emission[, Food_Type := ifelse(`Animal Feed` > 0, "Animal-Based", "Plant-Based")]
ggplot(food_emission, aes(x = `Food product`, y = Total_emissions, color = Total_emissions, size = Total_emissions)) +
geom_point(alpha = 0.8) +
theme_classic() +
scale_color_gradientn(colors = brewer.pal(9, "Paired"), name = "Total Emissions") +
scale_size(range = c(3, 6), name = "Total Emissions") +
labs(
title = "Total Emission by Foods",
x = " ",
y = "Total Emissions"
) +
theme(plot.title = element_text(size = 16, face = "bold"),
axis.text.x = element_text(angle = 45, hjust = 1, size = 6.5), # Rotate x-axis labels and adjust size
legend.position = "bottom",
legend.title = element_text(size = 8),
legend.text = element_text(size = 6),
legend.key.size = unit(0.5, "cm")
)
Few of the foods contribute to most of the carbon footprint. It is generally observed that animal-based products (such as beef, dairy, and lamb) have higher emissions. It Looks like Beef is responsible for most of the greenhouse gas emissions. Plant based foods seem to be hardly visible in the graph indicating their significanly low carbon footprint.¶However, to give the best comparision between plant based food and animal based food, we need to take a closer look on the following plots.
ggplot(food_emission, aes(x = reorder(`Food product`, -Total_emissions), y = Total_emissions)) +
geom_bar(stat = "identity", fill = "skyblue2") +
geom_hline(yintercept = average_emissions, linetype = "dashed", color = "lightcoral", size = 0.8) + # Thêm đường nét đứt
theme_classic() +
labs(
title = "Impact of Food Types on the Environment",
x = "Food Product",
y = "Total Emissions"
) +
coord_flip() +
theme(
plot.title = element_text(size = 16, face = "bold"),
axis.text.y = element_text(size = 5.8),
axis.title.y = element_blank(),
legend.position = "none"
)
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
Similar to the previous chart, in this chart, beef,
lamb, and cheese are the top contributors to
greenhouse gas emissions. Surprisingly, right after them are two
plant-based products: dark chocolate and
coffee. Compared to the average emissions, these products
have a significant gap from the greenhouse gas emissions per kilogram of
food product average emission. Nuts,
citrus fruit, and root vegetables are the food
products that contribute the least to the greenhouse gas effect.
ggplot(emissions_summary, aes(x = reorder(Production_Stage, Total_Emissions), y = Total_Emissions, fill = Production_Stage)) +
geom_bar(stat = "identity") +
theme_classic() +
labs(
title = "Contribution of Food Production Stages to GHG",
x = "Production Stage",
y = "Total Greenhouse Gas Emissions"
) +
coord_flip() +
theme(
plot.title = element_text(size = 13, face = "bold"),
legend.title = element_text(size = 8),
legend.text = element_text(size = 6.5)
)
The Farm phase is the most significant contributor to
greenhouse gas emissions. Factors such as transport, distance, retail,
and packaging are often smaller in comparison to the importance of the
type of food.
ggplot(food_emission[Food_Type == "Plant-Based"], aes(x = `Food product`, y = Total_emissions, color = Total_emissions, size = Total_emissions)) +
geom_point(alpha = 0.8) +
theme_classic() +
scale_color_gradientn(colors = brewer.pal(5, "YlGn"), name = "Total Emissions") +
scale_size(range = c(3, 6), name = "Total Emissions") +
labs(
title = "Carbon Footprint of Plant-Based Foods Compared to Average",
x = " ",
y = "Total Emissions"
) +
geom_hline(yintercept = average_emissions, linetype = "dashed", color = "red") +
theme(plot.title = element_text(size = 13.5, face = "bold"),
axis.text.y = element_text(size = 5.5),
legend.position = "bottom",
legend.title = element_text(size = 8),
legend.text = element_text(size = 6),
legend.key.size = unit(0.5, "cm")
) +
coord_flip()
In general, most of plant-based food products are under the average.
There are some extreme observation , such as Coffee and
Dark chocolate, which exhibit a substantial gap compared to
the average emission level. Following them closely is
Palm Oil.
ggplot(food_emission[Food_Type == "Animal-Based"], aes(x = `Food product`, y = Total_emissions, color = Total_emissions, size = Total_emissions)) +
geom_point(alpha = 0.8) +
theme_classic() +
scale_color_gradientn(colors = brewer.pal(4, "Reds"), name = "Total Emissions") +
scale_size(range = c(3, 6), name = "Total Emissions") +
labs(
title = "Carbon Footprint of Animal-Based Foods Compared to Average",
x = " ",
y = "Total Emissions"
) +
geom_hline(yintercept = average_emissions, linetype = "dashed", color = "red") +
theme(plot.title = element_text(size = 12, face = "bold"),
axis.text.x = element_text(angle = 45, hjust = 1, size = 6.5),
legend.position = "bottom",
legend.title = element_text(size = 8),
legend.text = element_text(size = 6),
legend.key.size = unit(0.5, "cm")
) +
coord_flip()
Similar to the previous charts, products from beef, lamb, and cheese all maintain a significant gap compared to the average emission level, especially beef-herb.
ggplot(food_emission, aes(x = reorder(`Food product`, `Land use change`), y = `Land use change`)) +
geom_bar(stat = "identity", fill = "plum3") +
theme_classic() +
labs(
title = "Food Distribution by Emissions via Land Use Change",
x = "Food Product",
y = "Emissions from Land Use Change"
) +
coord_flip()
theme(
plot.title = element_text(size = 18, face = "bold"),
axis.text.y = element_text(size = 5.5)
)
## List of 2
## $ axis.text.y:List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : num 5.5
## ..$ hjust : NULL
## ..$ vjust : NULL
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : NULL
## ..$ debug : NULL
## ..$ inherit.blank: logi FALSE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## $ plot.title :List of 11
## ..$ family : NULL
## ..$ face : chr "bold"
## ..$ colour : NULL
## ..$ size : num 18
## ..$ hjust : NULL
## ..$ vjust : NULL
## ..$ angle : NULL
## ..$ lineheight : NULL
## ..$ margin : NULL
## ..$ debug : NULL
## ..$ inherit.blank: logi FALSE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## - attr(*, "class")= chr [1:2] "theme" "gg"
## - attr(*, "complete")= logi FALSE
## - attr(*, "validate")= logi TRUE
Beef herb, Dark chocolate,
Cheese, Coffee, Soil bean oil,
and Palm oil are all on the list of products causing
extremely significant negative impact on the land environment,
especially Beef herb and Dark chocolate.
Interestingly, Nuts, Olive oil,
Citrus fruit, and Wine have a slight positive
impact on the land environment.
ggplot(food_emission, aes(x = reorder(`Food product`, -`Farm`), y = `Farm`)) +
geom_bar(stat = "identity", fill = "darkgreen") +
theme_classic() +
labs(
title = "Food Distribution by Emissions via Farm",
x = "Food Product",
y = "Emissions from Farm"
) +
coord_flip() +
theme(
plot.title = element_text(size = 16, face = "bold"),
axis.text.y = element_text(size = 5.5)
)
No surprises there when animal-based food products dominate the top
positions for emitting the most greenhouse gases during the farm phase,
especially Beef, Lamb, and
Cheese. Surprisingly, during this phase,
Olive oil precedes Dark chocolate (a food
product that stands at the top 6 products of the total emission
list).
A heatmap visualizes the correlation between different attributes of foods, offering insights into relationships between various production stages.
# Calculate the matrix
cor_matrix <- cor(food_emission[, .SD, .SDcols = c("Land use change", "Animal Feed", "Farm", "Processing", "Transport", "Packging", "Retail")])
melted_cor_matrix <- melt(cor_matrix)
ggplot(data = melted_cor_matrix, aes(Var1, Var2, fill = value)) +
geom_tile() +
scale_fill_gradient2(low = "deepskyblue", high = "deepskyblue3", mid = "white", midpoint = 0, limit = c(-1, 1)) +
theme_minimal() +
labs(title = "Heatmap of the Correlation between Food Attributes", x = "Attribute", y = "Attribute", fill = "Correlation") +
theme(axis.text.x = element_text(angle = 35,vjust = 1, hjust = 1))
From the matrix, it’s evident that there are some positive correlations between Land use change and Farm, or Farm and Processing, or Retail and Animal feed. This opens up interesting questions for future research to delve deeper into the relationships between different phases of food production and their greenhouse gas effects.
This analysis offers a comprehensive overview of the environmental impact of different food products, identifying key areas where the food production process contributes to greenhouse gas emissions. Through targeted data visualization, we can better understand the relationship between food production stages and their environmental impact, as well as compare the impact of animal-based and plant-based foods. These insights are crucial for informing both consumers and producers about sustainable food choices and practices. This simple analysis and visualization can indeed pave the way for more in-depth research into each factor and type of food, exploring how they contribute to the greenhouse gas effect. For instance, investigating why dark chocolate and coffee, despite being plant-based food products, play a significant role in causing greenhouse gas emissions would be a fascinating avenue of research.