Valentine’s Day Consuming Patterns

Author

Tal Guttman

About the Data

The data are consumers’ data on Valentine’s Day throughout the years 2010-2022. It shows what the consumers spent their money on, in Dollars.

The data is taken from TidyTuesday of February 13th, 2024.

Pie Chart

I present the amount of money consumers spent every year on different kinds of products. I found an interesting pattern: as the years go by, consumers tend to spend more money for things they can hold rather than things they can live.

#packages needed for code:

suppressWarnings({
  suppressPackageStartupMessages({
library(ggplot2)
library(gganimate)
library(dplyr)
library(tidyr)
library(scales)
library(gifski)
library(magick)
library(png)
library(tidytuesdayR)
    })
  })
extrafont::loadfonts(quiet = TRUE)

#data arrangements:

suppressWarnings({
  suppressPackageStartupMessages({
data_source <- tt_load("2024-02-13")
raw_data <- data_source$historical_spending
   })
  })

    Downloading file 1 of 3: `historical_spending.csv`
    Downloading file 2 of 3: `gifts_age.csv`
    Downloading file 3 of 3: `gifts_gender.csv`
classification <- data.frame(
  Variable = colnames(raw_data)[4:10],  
  Category = factor(c("Experience", "Stuff", "Stuff", "Stuff", "Experience", "Stuff", "Stuff"), levels = c("Experience", "Stuff"))
)

raw_data_long <- raw_data %>%
  pivot_longer(cols = Candy:GiftCards,
               names_to = "Variable",
               values_to = "Value") %>%
  left_join(classification, by = "Variable")  %>%
  select(-PerPerson, -PercentCelebrating)

raw_data_long <- raw_data_long %>%
  group_by(Year) %>%
  mutate(Proportion = Value / sum(Value)) %>%
  ungroup()

raw_data_long <- raw_data_long %>%
  mutate(Classification = ifelse(Variable %in% c("EveningOut"), "Experience", "Stuff"))

#plotting:

custom_colors <- c("Experience" = "darkgoldenrod2",
                   "Stuff" = "deepskyblue4")

animated_pie_chart <- ggplot(raw_data_long, aes(x = "", y = Proportion, fill = Classification)) +
  geom_bar(width = 1, stat = "identity") +
  coord_polar(theta = "y") +
  geom_text(aes(label = paste(Variable), fontface = "bold"), 
            color = "white", size = 3, position = position_stack(vjust = 0.5)) +
  theme_void() +
  labs(title = "Money Spent on Experiences or Stuff in {closest_state}", fill = "Classification") +
  scale_fill_manual(values = custom_colors, labels = c("Experience" = "Experience", "Stuff" = "Stuff")) +
  transition_states(Year, transition_length = 10, state_length = 1) +
  ease_aes('linear')

animated_pie_chart

This visualization suggest a slight trend of increase in money spent on stuff rather than experiences along the years.

Review Notes

  1. Add percentages to the pie chart to make the changes clearer.
  2. Adjust the colors to the variables, e. g., red and pink to demonstrate Valentine’s Day gifts.
  3. Phrase more informative graph title.

Fixed Pie Chart

#packages needed for code:

suppressWarnings({
  suppressPackageStartupMessages({
library(ggplot2)
library(gganimate)
library(dplyr)
library(tidyr)
library(scales)
library(gifski)
library(magick)
library(png)
})
})

#data arrangements:

suppressWarnings({
  suppressPackageStartupMessages({
data_source <- tt_load("2024-02-13")
raw_data <- data_source$historical_spending
   })
  })
--- Compiling #TidyTuesday Information for 2024-02-13 ----
--- There are 3 files available ---
--- Starting Download ---

    Downloading file 1 of 3: `historical_spending.csv`
    Downloading file 2 of 3: `gifts_age.csv`
    Downloading file 3 of 3: `gifts_gender.csv`
--- Download complete ---
classification <- data.frame(
  Variable = colnames(raw_data)[4:10],  # Columns from the fourth to the last one
  Category = factor(c("Experience", "Stuff", "Stuff", "Stuff", "Experience", "Stuff", "Stuff"), levels = c("Experience", "Stuff"))
)

raw_data_long <- raw_data %>%
  pivot_longer(cols = Candy:GiftCards,
               names_to = "Variable",
               values_to = "Value") %>%
  left_join(classification, by = "Variable")  %>%
  select(-PerPerson, -PercentCelebrating)

raw_data_long <- raw_data_long %>%
  group_by(Year) %>%
  mutate(Proportion = Value / sum(Value),
         Percentage = scales::percent(Proportion)) %>%
  ungroup()

raw_data_long <- raw_data_long %>%
  mutate(Classification = ifelse(Variable %in% c("EveningOut"), "Experience", "Stuff"))

#plotting:

custom_colors <- c("Experience" = "pink",
                   "Stuff" = "darkred")

animated_pie_chart <- ggplot(raw_data_long, aes(x = "", y = Proportion, fill = Classification)) +
  geom_bar(width = 1, stat = "identity") +
  coord_polar(theta = "y") +
  geom_text(aes(label = paste(Variable, Percentage), fontface = "bold"), 
            color = "white", size = 3, position = position_stack(vjust = 0.5)) +
  theme_void() +
  labs(title = "Percentage of Money Spent on Experiences or Stuff on Valentine's Day in {closest_state}", fill = "Classification") +
  scale_fill_manual(values = custom_colors, labels = c("Experience" = "Experience", "Stuff" = "Stuff")) +
  transition_states(Year, transition_length = 10, state_length = 1) +
  ease_aes('linear')

animated_pie_chart


**The years 2020-2021 were years of COVID-19 pandemic which might interfere with the trend I suggested, since quarantines prevented people from going out.