3  Results

  1. The meat production in different continents
Code
# Interactive
library(tidyverse)
── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
✔ ggplot2 3.4.0     ✔ purrr   1.0.2
✔ tibble  3.2.1     ✔ dplyr   1.1.3
✔ tidyr   1.3.0     ✔ stringr 1.5.1
✔ readr   2.1.2     ✔ forcats 0.5.1
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
Code
library(readr)
library(ggplot2)
global_meat_production <- read_csv("global-meat-production.csv")
Rows: 14140 Columns: 4
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (2): Entity, Code
dbl (2): Year, Meat

ℹ 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.
Code
#View(global_meat_production)
Africa <- global_meat_production |>
  filter(Entity == "Africa")
Oceania <- global_meat_production |>
  filter(Entity == "Oceania")
South_America <- global_meat_production |>
  filter(Entity == "South America")
North_America <- global_meat_production |>
  filter(Entity == "North America")
Europe <- global_meat_production |>
  filter(Entity == "Europe")
Asia <- global_meat_production |>
  filter(Entity == "Asia")

df <- data.frame(year = Africa$Year, 
                 Africa_meat_production = Africa$Meat,
                 Oceania_meat_production = Oceania$Meat,
                 South_America_meat_production = South_America$Meat,
                 North_America_meat_production = North_America$Meat,
                 Europe_meat_production = Europe$Meat,
                 Asia_meat_production = Asia$Meat)

library(plotly)

Attaching package: 'plotly'

The following object is masked from 'package:ggplot2':

    last_plot

The following object is masked from 'package:stats':

    filter

The following object is masked from 'package:graphics':

    layout
Code
# Melt the data frame to long format for better compatibility with plot_ly
library(reshape2)

Attaching package: 'reshape2'

The following object is masked from 'package:tidyr':

    smiths
Code
df_long <- melt(df, id.vars = "year")

# Create an interactive line chart
p <- plot_ly(data = df_long, x = ~year, y = ~value, color = ~variable, type = 'scatter', mode = 'lines+markers') %>%
  layout(title = "Interactive Meat Production Over Years",
         xaxis = list(title = "Year"),
         yaxis = list(title = "Meat Production (tonnes)"))

# Display the plot
p
Code
#Static
ggplot(df, aes(x = year)) +
  geom_ribbon(aes(ymin = 0, ymax = Africa_meat_production, fill = "Africa"), alpha = 0.3) +
  geom_ribbon(aes(ymin = 0, ymax = Oceania_meat_production, fill = "Oceania"), alpha = 0.3) +
  geom_ribbon(aes(ymin = 0, ymax = South_America_meat_production, fill = "South America"), alpha = 0.3) +
  geom_ribbon(aes(ymin = 0, ymax = North_America_meat_production, fill = "North America"), alpha = 0.3) +
  geom_ribbon(aes(ymin = 0, ymax = Europe_meat_production, fill = "Europe"), alpha = 0.3) +
  geom_ribbon(aes(ymin = 0, ymax = Asia_meat_production, fill = "Asia"), alpha = 0.3) +
  geom_line(aes(y = Africa_meat_production, color = "Africa"), size = 1) +
  geom_line(aes(y = Oceania_meat_production, color = "Oceania"), size = 1) +
  geom_line(aes(y = South_America_meat_production, color = "South America"), size = 1) +
  geom_line(aes(y = North_America_meat_production, color = "North America"), size = 1) +
  geom_line(aes(y = Europe_meat_production, color = "Europe"), size = 1) +
  geom_line(aes(y = Asia_meat_production, color = "Asia"), size = 1) +
  labs(title = "Meat Production Over Years",
       x = "Year",
       y = "Meat Production (tonnes)",
       color = "Region") +
  theme_minimal()
Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
ℹ Please use `linewidth` instead.

  1. The meat production in several big targeting countries
Code
#interactive
global_meat_production <- read_csv("global-meat-production.csv")
Rows: 14140 Columns: 4
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (2): Entity, Code
dbl (2): Year, Meat

ℹ 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.
Code
#View(global_meat_production)
China <- global_meat_production |>
  filter(Entity == "China")
United_States <- global_meat_production |>
  filter(Entity == "United States")
India <- global_meat_production |>
  filter(Entity == "India")
United_Kingdom <- global_meat_production |>
  filter(Entity == "United Kingdom")
Sri_Lanka <- global_meat_production |>
  filter(Entity == "Sri Lanka")
Macao <- global_meat_production |>
  filter(Entity == "Macao")
Saint_Vincent <- global_meat_production |>
  filter(Entity == "Saint Vincent and the Grenadines")

df2 <- data.frame(year = China$Year, 
                 China_meat_production = China$Meat,
                 United_States_meat_production = United_States$Meat,
                 India_meat_production = India$Meat,
                 United_Kingdom_meat_production = United_Kingdom$Meat,
                 Sri_Lanka_meat_production = Sri_Lanka$Meat,
                 Macao_meat_production = Macao$Meat,
                 Saint_Vincent_meat_production = Saint_Vincent$Meat)

df_long2 <- melt(df2, id.vars = "year")

# Create an interactive line chart
p <- plot_ly(data = df_long2, x = ~year, y = ~value, color = ~variable, type = 'scatter', mode = 'lines+markers') %>%
  layout(title = "Interactive Meat Production Over Years",
         xaxis = list(title = "Year"),
         yaxis = list(title = "Meat Production (tonnes)"))

# Display the plot
p
  1. World beef production
Code
library(readr)
beef_and_buffalo_meat_production_tonnes <- read_csv("beef-and-buffalo-meat-production-tonnes.csv")
Rows: 13810 Columns: 4
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (2): Entity, Code
dbl (2): Year, Meat, beef and buffalo | 00001806 || Production | 005510 || t...

ℹ 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.
Code
# Assuming your data frame is named 'beef_data'
# Filter rows without NA values
filtered_data <- na.omit(beef_and_buffalo_meat_production_tonnes)

# Install and load necessary packages
# install.packages(c("plotly", "maps", "rworldmap"))
library(plotly)
library(maps)

Attaching package: 'maps'

The following object is masked from 'package:purrr':

    map
Code
library(rworldmap)
Loading required package: sp
### Welcome to rworldmap ###
For a short introduction type :      vignette('rworldmap')
Code
library(viridis)
Loading required package: viridisLite

Attaching package: 'viridis'

The following object is masked from 'package:maps':

    unemp
Code
# Create an interactive world map plot
fig <- plot_ly(data = filtered_data, type = 'choropleth', locations = ~Code, locationmode = "ISO-3", z = ~`Meat, beef and buffalo | 00001806 || Production | 005510 || tonnes`,
               color = ~`Meat, beef and buffalo | 00001806 || Production | 005510 || tonnes`, colors = viridis(20),  # Use viridis colors
               hovertext = ~paste("Country: ", Code, "<br>Year: ", Year, "<br>Beef Production: ", `Meat, beef and buffalo | 00001806 || Production | 005510 || tonnes`),
               animation_frame = ~Year,
               colorbar = list(title = 'Beef Production'))

# Display the plot
fig
Warning: 'choropleth' objects don't have these attributes: 'animation_frame'
Valid attributes include:
'autocolorscale', 'coloraxis', 'colorbar', 'colorscale', 'customdata', 'customdatasrc', 'featureidkey', 'geo', 'geojson', 'hoverinfo', 'hoverinfosrc', 'hoverlabel', 'hovertemplate', 'hovertemplatesrc', 'hovertext', 'hovertextsrc', 'ids', 'idssrc', 'legendgroup', 'legendgrouptitle', 'legendrank', 'locationmode', 'locations', 'locationssrc', 'marker', 'meta', 'metasrc', 'name', 'reversescale', 'selected', 'selectedpoints', 'showlegend', 'showscale', 'stream', 'text', 'textsrc', 'transforms', 'type', 'uid', 'uirevision', 'unselected', 'visible', 'z', 'zauto', 'zmax', 'zmid', 'zmin', 'zsrc', 'key', 'set', 'frame', 'transforms', '_isNestedKey', '_isSimpleKey', '_isGraticule', '_bbox'
  1. per capita meat type in 2020
Code
library(tidyverse)

# Assuming your data is named 'meat_data'
# Skip the first row (description) and assign column names
meat_data <- read.table(text = "Entity Meat_poultry Beef Sheep_goat Pig Other Fish_seafood
1 Argentina 46.3939700 47.096455 1.4250365 14.47114700 1.1540788 6.8040480
2 Brazil 48.2454450 35.304220 0.6480582 14.14761000 0.5084764 8.0558620
3 China 15.1313200 6.737377 3.7979817 35.69698700 0.5252528 40.3333550
4 Ethiopia 0.5787864 3.688538 2.3445760 0.01961988 1.1085232 0.5297368
5 India 2.5694962 1.126625 0.5929607 0.23718427 0.0000000 7.8863770
6 Japan 22.4991100 9.654016 0.1514752 21.53976600 0.1009834 46.6543460
7 Portugal 30.2687700 18.565240 2.1090117 37.71467000 0.6633980 59.3592700
8 United_Kingdom 33.1334100 17.563847 3.9885620 24.33630400 1.0528184 18.1307490
9 United_States 57.8270800 37.313194 0.6010312 30.18949900 0.7980906 22.4549200", header = TRUE)

# Reshape the data into long format
meat_data_long <- meat_data %>%
  pivot_longer(cols = -Entity, names_to = "Meat_Type", values_to = "Consumption")

# Create a stacked bar chart
ggplot(meat_data_long, aes(x = Entity, y = Consumption, fill = Meat_Type)) +
  geom_bar(stat = "identity") +
  labs(title = "Meat Consumption by Country",
       x = "Country",
       y = "Consumption",
       fill = "Meat Type") +
  theme_minimal()

  1. Interactive stacked bar chart
Code
library(tidyverse)
library(plotly)

# Assuming your data is named 'meat_data'
meat_data <- read.table(text = "Entity Meat_poultry Beef Sheep_goat Pig Other Fish_seafood
1 Argentina 46.3939700 47.096455 1.4250365 14.47114700 1.1540788 6.8040480
2 Brazil 48.2454450 35.304220 0.6480582 14.14761000 0.5084764 8.0558620
3 China 15.1313200 6.737377 3.7979817 35.69698700 0.5252528 40.3333550
4 Ethiopia 0.5787864 3.688538 2.3445760 0.01961988 1.1085232 0.5297368
5 India 2.5694962 1.126625 0.5929607 0.23718427 0.0000000 7.8863770
6 Japan 22.4991100 9.654016 0.1514752 21.53976600 0.1009834 46.6543460
7 Portugal 30.2687700 18.565240 2.1090117 37.71467000 0.6633980 59.3592700
8 United_Kingdom 33.1334100 17.563847 3.9885620 24.33630400 1.0528184 18.1307490
9 United_States 57.8270800 37.313194 0.6010312 30.18949900 0.7980906 22.4549200", header = TRUE)

# Reshape the data into long format
meat_data_long <- meat_data %>%
  pivot_longer(cols = -Entity, names_to = "Meat_Type", values_to = "Consumption")

# Create interactive stacked bar chart using plotly
plot_ly(meat_data_long, x = ~Entity, y = ~Consumption, color = ~Meat_Type, type = "bar") %>%
  layout(title = "Interactive Stacked Bar Chart - Meat Consumption by Country",
         xaxis = list(title = "Country"),
         yaxis = list(title = "Consumption"),
         barmode = "stack")
  1. Different types of meat consumption correlation
Code
# Assuming 'meat_data' is your data frame with meat consumption
library(tidyverse)
library(corrplot)
corrplot 0.92 loaded
Code
# Skip the first row (description) and assign column names
meat_data <- read.table(text = "Entity Meat_poultry Beef Sheep_goat Pig Other Fish_seafood
1 Argentina 46.3939700 47.096455 1.4250365 14.47114700 1.1540788 6.8040480
2 Brazil 48.2454450 35.304220 0.6480582 14.14761000 0.5084764 8.0558620
3 China 15.1313200 6.737377 3.7979817 35.69698700 0.5252528 40.3333550
4 Ethiopia 0.5787864 3.688538 2.3445760 0.01961988 1.1085232 0.5297368
5 India 2.5694962 1.126625 0.5929607 0.23718427 0.0000000 7.8863770
6 Japan 22.4991100 9.654016 0.1514752 21.53976600 0.1009834 46.6543460
7 Portugal 30.2687700 18.565240 2.1090117 37.71467000 0.6633980 59.3592700
8 United_Kingdom 33.1334100 17.563847 3.9885620 24.33630400 1.0528184 18.1307490
9 United_States 57.8270800 37.313194 0.6010312 30.18949900 0.7980906 22.4549200", header = TRUE)

# Remove the 'Entity' column before calculating the correlation
cor_matrix <- cor(meat_data[, -1])

# Draw the correlation matrix using corrplot
corrplot(cor_matrix, method = "color", type = "upper", tl.col = "black")

  1. Heatmap of global meat consumption
Code
library(readr)
per_capita_meat_type <- read_csv("per-capita-meat-type.csv")
Rows: 12360 Columns: 9
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (2): Entity, Code
dbl (7): Year, Meat, poultry | 00002734 || Food available for consumption | ...

ℹ 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.
Code
heatmap_data <- per_capita_meat_type|>
  rename(Meat_poultry = "Meat, poultry | 00002734 || Food available for consumption | 0645pc || kilograms per year per capita")
heatmap_data<- heatmap_data|>
  rename(Beef = "Meat, beef | 00002731 || Food available for consumption | 0645pc || kilograms per year per capita")
heatmap_data<- heatmap_data|>
  rename(Sheep_goat = "Meat, sheep and goat | 00002732 || Food available for consumption | 0645pc || kilograms per year per capita")
heatmap_data<- heatmap_data|>
  rename(Pig = "Meat, pig | 00002733 || Food available for consumption | 0645pc || kilograms per year per capita")
heatmap_data<- heatmap_data|>
  rename(Other = "Meat, Other | 00002735 || Food available for consumption | 0645pc || kilograms per year per capita")
heatmap_data<- heatmap_data|>
  rename(Fish_seafood = "Fish and seafood | 00002960 || Food available for consumption | 0645pc || kilograms per year per capita")
heatmap_data<- heatmap_data|>
  select(-Code) |>
  select(-Entity) |>
  filter(Year == 2020) |>
  select(-Year) |> as.matrix()
  
heatmap(heatmap_data[,-1])

  1. Top five meat consumption entity
Code
another_data2 = read.table(text = "Entity total
1 Hong_Kong 202.02289
2 Macao 169.80333
3 Iceland 168.28322
4 United_States 149.18381
5 Portugal 148.68036", header = TRUE)
ggplot(another_data2, aes(x = Entity, y = total, fill = Entity)) +
  geom_bar(stat = "identity") +
  labs(title = "Total Values by Entity",
       x = "Entity",
       y = "Total") +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))  # Rotate x-axis labels for better readability

  1. Top five region meat consumption static
Code
another_data <- per_capita_meat_type|>
  select(-Code) |>
  filter(Entity == 'Hongkong' 
         | Entity =='United States'
         | Entity =='Iceland'
         | Entity =='Macao'
         | Entity =='Portugal')
another_data<-another_data|>
  rename(Meat_poultry = "Meat, poultry | 00002734 || Food available for consumption | 0645pc || kilograms per year per capita")
another_data<-another_data|>
  rename(Beef = "Meat, beef | 00002731 || Food available for consumption | 0645pc || kilograms per year per capita")
another_data<-another_data|>
  rename(Sheep_goat = "Meat, sheep and goat | 00002732 || Food available for consumption | 0645pc || kilograms per year per capita")
another_data<-another_data|>
  rename(Pig = "Meat, pig | 00002733 || Food available for consumption | 0645pc || kilograms per year per capita")
another_data<-another_data|>
  rename(Other = "Meat, Other | 00002735 || Food available for consumption | 0645pc || kilograms per year per capita")
another_data<-another_data|>
  rename(Fish_seafood = "Fish and seafood | 00002960 || Food available for consumption | 0645pc || kilograms per year per capita")


# Assuming 'your_data' is your data frame
another_data <- replace(another_data, is.na(another_data), 0) |>
  mutate(total = Meat_poultry + Beef + Sheep_goat + Pig + Other + Fish_seafood)


ggplot(another_data, aes(x = Year, y = total, group = Entity, color = Entity)) +
  geom_line() +
  labs(title = "Growth Trend of Total Meat Consumption Over Years",
       x = "Year",
       y = "Total") +
  theme_minimal() +
  facet_wrap(~Entity, scales = "free_y")

  1. Top five region meat consumption interactive
Code
library(plotly)

# Assuming 'another_data' is your data frame
plot_list <- lapply(unique(another_data$Entity), function(entity) {
  subset_data <- another_data[another_data$Entity == entity, ]
  plot_ly(subset_data, x = ~Year, y = ~total, type = "scatter", mode = "lines", name = entity) %>%
    layout(title = paste("Growth Trend of Total Meat Consumption Over Years -", entity),
           xaxis = list(title = "Year"),
           yaxis = list(title = "Total"))
})

subplot(plot_list, nrows = length(unique(another_data$Entity)), margin = 0.05)

Some of the findings:

The world meat consumption total amount is increasing in the past 50 years, and for each sub category of the meat, like fish, beef, poultry, they are all increasing. There is no clear correlation between the different types of meat consumption amount. And in the world, US, China, Brazil has the highest beef production amount. In our comprehensive exploration of global meat production over the past 50 years reveals a fourfold increase in total output since 1961. Asia has emerged as the leading contributor, accounting for 40-45 percent of the world’s meat production, marking a significant shift from the dominance of Europe and North America in 1961. Despite a decline in production share, both Europe and North America witnessed substantial absolute increases in meat output, while Asia’s production soared by an astounding 15-fold.

The analysis also underscores the dynamic shifts in meat types, with poultry’s share tripling to approximately 35 percent by 2013, while the share of beef and buffalo meat nearly halved to around 22 percent. Pigmeat’s share remained relatively constant at 35-40 percent. These findings underscore the evolving landscape of global meat production, reflecting changes in regional contributions and shifts in preferences for specific meat types over the past five decades.