Please carefully read the statements below and check each box if you agree with the declaration. If you do not check all boxes, your assignment will not be marked. If you make a false declaration on any of these points, you may be investigated for academic misconduct. Students found to have breached academic integrity may receive official warnings and/or serious academic penalties. Please read more about academic integrity here. If you are unsure about any of these points or feel your assessment might breach academic integrity, please contact your course coordinator for support. It is important that you DO NOT submit any assessment until you can complete the declaration truthfully.
By checking the boxes below, I declare the following:
I have not impersonated, or allowed myself to be impersonated by, any person for the purposes of this assessment
This assessment is my original work and no part of it has been copied from any other source except where due acknowledgement is made.
No part of this assessment has been written for me by any other person except where such collaboration has been authorised by the lecturer/teacher concerned.
Where this work is being submitted for individual assessment, I declare that it is my original work and that no part has been contributed by, produced by or in conjunction with another student.
I give permission for my assessment response to be reproduced, communicated compared and archived for the purposes of detecting plagiarism.
I give permission for a copy of my assessment to be retained by the university for review and comparison, including review by external examiners.
I understand that:
Plagiarism is the presentation of the work, idea or creation of another person as though it is your own. It is a form of cheating and is a very serious academic offence that may lead to exclusion from the University. Plagiarised material can be drawn from, and presented in, written, graphic and visual form, including electronic data and oral presentations. Plagiarism occurs when the origin of the material used is not appropriately cited.
Plagiarism includes the act of assisting or allowing another person to plagiarise or to copy my work.
I agree and acknowledge that:
I have read and understood the Declaration and Statement of Authorship above.
If I do not agree to the Declaration and Statement of Authorship in this context and all boxes are not checked, the assessment outcome is not valid for assessment purposes and will not be included in my final result for this course.
The original data visualisation selected for the assignment was as follows:
The objective and audience of the original data visualisation chosen can be summarised as follows:
Objective The original visualization aims to compare the per capita meat consumption by type across selected countries in 2020, specifically highlighting the US in context with Italy, Germany, and Japan.
Audience The primary audience includes stakeholders interested in dietary trends such as nutritionists, policy makers, environmentalists, as well as the general public interested in meat consumption patterns.
The visualisation chosen had the following three main issues:
The following code was used to fix the issues identified in the original.
rm(list=ls()) # Clean R's memory!
library(dplyr)
library(ggplot2)
library(tidyr)
# Load and filter data
rawdata <- read.csv("per-capita-meat-type.csv", header = TRUE)
filtered_data <- rawdata %>%
filter(Entity %in% c("Italy", "Germany", "Hong Kong", "Australia", "United States", "Japan"), Year == 2020)
# Rename columns
names(filtered_data)[1] <- "Country"
names(filtered_data)[4] <- "Poultry"
names(filtered_data)[5] <- "Beef"
names(filtered_data)[7] <- "Pig"
names(filtered_data)[9] <- "Seafood"
# Select and prepare the final dataframe
df1 <- filtered_data %>%
select(Country, Poultry, Beef, Pig, Seafood) %>%
mutate(across(c(Poultry, Beef, Pig, Seafood), ~ ceiling(.x)))
# Transform from wide to long
long_data <- df1 %>%
pivot_longer(cols = -Country, names_to = "MeatType", values_to = "Consumption") %>%
group_by(Country) %>%
arrange(Country, desc(MeatType)) %>%
mutate(LabelPos = cumsum(Consumption) - 0.5 * Consumption)
# Adding country order based on total consumption
long_data$Country <- reorder(long_data$Country, long_data$Consumption, FUN = sum)
# Calculate the total meat consumption for each country and the position for total labels
country_totals <- long_data %>%
group_by(Country) %>%
summarize(TotalConsumption = sum(Consumption), .groups = 'drop') %>%
mutate(Position = TotalConsumption) # This adds the Position column used for placing the total consumption label
The following plot fixes the main issues in the original.
# Define custom colors
custom_colors <- c("Seafood" = "navy", "Pig" = "pink", "Beef" = "darkred", "Poultry" = "tan")
# Creating the plot with all adjustments
ggplot(long_data, aes(x = Country, y = Consumption, fill = MeatType)) +
geom_bar(stat = "identity", position = "stack") +
geom_text(aes(label = Consumption, y = LabelPos), vjust = 0.5, color = "white", size = 3, fontface = "bold") +
geom_text(data = country_totals,
aes(x = Country, label = TotalConsumption, y = Position),
vjust = -0.5, color = "black", size = 3.5,
inherit.aes = FALSE) + # Prevent inheriting global aesthetics
theme_minimal() +
scale_fill_manual(values = custom_colors) +
labs(title = "Per Capita Meat Consumption by Country",
x = "Country",
y = "Consumption (kg per year)",
fill = "Type of Meat") +
theme_minimal()
The reference to the original data visualisation choose, the data source(s) used for the reconstruction and any other sources used for this assignment are as follows: