Tricia’s Theory of Everything

The goal of this page is to try to find the objectively best candle from the data I’ve collected so far. This could be a long one; you might want to get some snacks.

First things first, let’s start with the basics.

# loading libraries
library(readr)
library(dplyr)
library(here)
library(tidyverse)
brands <- read.csv("brands.csv")
burn_times <- read_csv("burn_times.csv")
materials <- read.csv("materials.csv")
purchases <- read.csv("purchases.csv")
head(brands)
head(burn_times)
head(materials)
head(purchases)

That’s so much data! What makes the most sense to measure? I know, let’s see if the type of wax makes a difference in the candle’s total burn time. To do this, we’ll need to join the materials and burn_times data frames. We’ll also need the weight of the candle from purchases. All three have the candle_id column in common.

wax_type <- burn_times %>%
  inner_join(materials, by = "candle_id") %>%
  inner_join(purchases, by = "candle_id") %>%
  select(session_time,wax,weight_oz)
wax_type

Since we’re just comparing the burn times to the type of wax, we only took the columns that we needed. Now we can do some calculations.

wax_type <- wax_type %>%
  group_by(wax) %>%
  summarise(across(where(is.numeric), sum)) %>%
  rename(total_time = session_time)
wax_type

We now have the total burn time for each type of wax, and we’ve renamed the column to reflect that. We also have the total weight of wax burned, and we can do some division to see a better view.

wax_type <- wax_type %>%
  mutate(hours_per_ounce = total_time / weight_oz)
wax_type

It looks like coconut might be the most efficient type of wax on average, as you get 0.52 hours - a little over 30 minutes - per each ounce of wax. Let’s pretty things up.

viz <- wax_type %>%
  arrange(hours_per_ounce) %>%
  mutate(wax=factor(wax,levels=wax)) %>%
  ggplot(aes(fill=wax,x=wax,y=hours_per_ounce)) + geom_bar(stat = "identity") + 
  labs(title="Waxing Poetic",subtitle="Does a candle's wax type make a difference in burn times?",y="Hours per Ounce") +
  theme(axis.title.x = element_blank(),legend.position = "none")
viz

Next, we’ll look at price. Do more expensive candles burn longer?