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
library(ggplot2)

# Load IPL matches dataset
matches <- read.csv("matches.csv")

# Count wins for each team
team_wins <- matches %>%
  group_by(winner) %>%
  summarise(wins = n())
## `summarise()` ungrouping output (override with `.groups` argument)
# Find the team with the most wins
most_successful_team <- team_wins %>%
  filter(wins == max(wins))

# Create a bar graph
ggplot(team_wins, aes(x = winner, y = wins)) +
  geom_bar(stat = "identity", fill = "skyblue") +
  labs(title = "IPL Team Wins by Season", 
       x = "Team", y = "Number of Wins") +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
  geom_text(aes(label = wins), vjust = -0.5)

# Print the results
cat("Most successful IPL team:", most_successful_team$winner, "\n")
## Most successful IPL team: Mumbai Indians