Scroll down for the fun bits!
Putting all the boring deleting of personally identifiable data and cleaning in here.
raw <- read_csv("Lizard - A Slate Pro-202404140002.csv", show_col_types = FALSE)
#Fixing the date_time
raw <- raw %>%
mutate(`Booking Date`= parse_date_time(`Booking Date`, c("%d/%m/%Y %I:%M:%S %p"))) %>%
mutate(`Modified Date` = parse_date_time(`Modified Date`, c("%d/%m/%Y %I:%M:%S %p")))
#Fixing attendee type
raw <- raw %>%
mutate(`Attendee Type` = factor(`Attendee Type`)) %>%
mutate(`Attendee Type` = fct_recode(`Attendee Type`,
Student = "NUS Student",
Public = "I am a Member of the Public",
Staff = "NUS Staff"))
#Adding a "Pax" row
raw <- raw %>%
mutate(Pax = `Line Number`*Quantity)
#Adding a "Total Cost" rowx
raw <- raw %>%
mutate(`Total Cost` = `Unit Amount`*Quantity)
#Removing tickets of quantity 0
raw <- raw %>% filter(Quantity>0)
#Removing Personal Identifiers
receipt <- raw %>% select(`Booking Date`, `Modified Date`, `Attendee Type`, `Line Number`, `Unit Amount`, `Unit Tax`, Quantity, Pax, `Total Cost`)
str(receipt)
total_seats_bought <- sum(receipt$Pax)
There have been 136 out 240 seats bought. That’s 56.67%
Will we be able to break even? Probably not. But is it fun to see? Kinda.
total_money <- sum(receipt$`Unit Amount`*receipt$Quantity)
after_gst <- sum(receipt$`Unit Amount`*receipt$Quantity - receipt$`Unit Tax`*receipt$Quantity)
We’ve received $1722, and made $1579.81 after GST. Wait how much money do we have to make back again?
I’ll do it after I catch up on datacamp I promise
type_of_seats <- receipt %>% group_by(`Line Number`) %>% summarise(`Total Tix Bought` = sum(Quantity))
type_of_seats <- type_of_seats %>% rename(`Seat Type` = `Line Number`)
type_of_seats
## # A tibble: 2 × 2
## `Seat Type` `Total Tix Bought`
## <dbl> <dbl>
## 1 1 30
## 2 2 53
30 out of 70 single seat tix have been bought. That’s 42.86%. 53 out of 110 double seat tix have been bought. That’s 48.18%.
Who’s buying the tickets? Whether it be members of the public, or NUS Students, or Staff.
people <- receipt %>% group_by(`Attendee Type`) %>% summarise(`Total No. of People` = sum(Pax)) %>% arrange(desc(`Total No. of People`))
people
## # A tibble: 3 × 2
## `Attendee Type` `Total No. of People`
## <fct> <dbl>
## 1 Student 91
## 2 Public 35
## 3 Staff 10
GRAPH!
day_tix <- receipt %>% mutate (day = date(`Booking Date`)) %>%
group_by(day, `Attendee Type`) %>%
summarise(total = sum(Pax)) %>%
complete(`Attendee Type`, fill = list(total = 0)) %>%
group_by(`Attendee Type`) %>%
mutate(cum = cumsum(total)) %>%
pivot_wider(names_from = `Attendee Type`, values_from = c(total, cum)) %>%
mutate (total_Total = total_Public+total_Staff+total_Student) %>%
mutate (cum_Total = cum_Public+cum_Staff+cum_Student) %>%
pivot_longer(cols = c(grep("cum_|total_", names(.), value = TRUE)),
names_to = c(".value", "Attendee Type"),
names_sep = "_")
## `summarise()` has grouped output by 'day'. You can override using the `.groups`
## argument.
day_tix |>
ggplot(mapping = aes(x = day, y = cum, color = `Attendee Type`)) +
geom_point() +
geom_line() +
theme_minimal() +
geom_text_repel(aes(label = cum), size = 4)+
labs(x = "Date", y = "Cumulative Tickets Bought")