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 median attendance is 40,284, and the mean attendance is approximately 41,040. I would use the median for interpretation because it is less affected by unusually high or low attendance values.

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 about 35,000 to 45,000 fans, with a few games reaching over 50,000. The graph shows that attendance varies across Dodgers games, with most games falling near the middle of the attendance range. There are fewer games with very low or very high attendance.

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. Attendance for both day and night games varied across the season.