Tip Amount in Relation to Delivery Distance

Introduction

This analysis explores how the delivery distance of taco orders affects the tip amount given by customers. The data comes from a taco delivery dataset.

Data Preparation

library(readr)
library(dplyr)

Attaching package: 'dplyr'
The following objects are masked from 'package:stats':

    filter, lag
The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union
# Load the data
df <- read_csv("Taco.csv")
Rows: 1000 Columns: 13
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (6): Restaurant_Name, Location, Order_Time, Delivery_Time, Taco_Size, Ta...
dbl (6): Order_ID, Delivery_Duration, Toppings_Count, Distance, Price, Tip
lgl (1): Weekend_Order

ℹ 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.
# Clean column names
colnames(df) <- trimws(colnames(df))

Visualization

A bar graph is created to visualize the relationship between delivery distance and tip amount.

library(ggplot2)

# Sort data by distance and plot
df_sorted <- df %>% arrange(Distance)

ggplot(df_sorted, aes(x = Distance, y = Tip)) +
  geom_bar(stat = "identity", fill = "skyblue") +
  labs(
    title = "Tip Amount in Relation to Delivery Distance",
    x = "Distance (miles)",
    y = "Tip ($)"
  ) +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))

Conclusion

This visualization helps understand tipping behavior based on delivery distance. For deeper insights, consider grouping distances and computing average tips per range.