Load the Data

data <- read.csv("DodgersData.csv")

Question 1

What is the median value of attendance? What is the mean value of attendance? Which value would you use for interpretation purposes? Why?

Mean <- mean(data$attend)
Median <- median(data$attend)

Mean
## [1] 41040.07
Median
## [1] 40284

The mean attendance is 41,040.07, while the median is 40,284. I would use the median because it is a clean number and does not have decimal in the end.

Question 2

Draw a graph with the ggplot package by following the example covered in Lab 4.

Graph 1

library(ggplot2)

ggplot(data, aes(x = attend)) +
  geom_histogram(
    binwidth = 5000,
    color = "black",
    fill = "lightblue"
  ) +
  labs(
    title = "Distribution of Dodgers Attendance",
    x = "Attendance",
    y = "Frequency"
  ) +
  theme_minimal()

Most Dodgers games had 35,000 to 45,000 fans, with a few games reaching over 50,000.

Graph 2

ggplot(data, aes(x = attend, fill = day_night)) +
  geom_histogram(bins = 30, col = "yellow") +
  scale_fill_manual(values = c("blue", "pink")) +
  ggtitle("Frequency of Attendance - Day vs. Night Games") +
  labs(
    x = "Attendance",
    y = "Frequency",
    fill = "Game Time"
  )

Night games occurred more often than day games while attendance for both day and night games varied across the season.