mydata <- read.csv("./attempts.csv", header = TRUE, sep = ",")
head(mydata)
##   serial player_name        club   position total_attempts on_target off_target
## 1      1     Benzema Real Madrid    Forward             45        23         13
## 2      2       Salah   Liverpool    Forward             42        22         11
## 3      3      Mahrez   Man. City Midfielder             37        18          8
## 4      4        Sané      Bayern Midfielder             33        13         12
## 5      5 Lewandowski      Bayern    Forward             31        19          8
## 6      6   Luis Díaz       Porto    Forward             29        11          7
##   blocked match_played
## 1       9           12
## 2       9           13
## 3      11           12
## 4       8           10
## 5       4           10
## 6      11           13

Source:https://www.kaggle.com/datasets/azminetoushikwasi/ucl-202122-uefa-champions-league?select=attempts.csv

This dataset contains all the player stats of UEFA Champions League season 2021-22 .

Im analyzing which team was has the highest accuracy average.

Description: serial: Identifier player_name: Name club: Club position: Position total_attempts: Totall Attempts on_target: On-Target off_target: Off-target blocked: Blocked match_played: Matches

summary(mydata[ ,-1:-4])
##  total_attempts     on_target        off_target        blocked      
##  Min.   : 1.000   Min.   : 0.000   Min.   : 0.000   Min.   : 0.000  
##  1st Qu.: 2.000   1st Qu.: 0.000   1st Qu.: 1.000   1st Qu.: 0.000  
##  Median : 4.000   Median : 1.000   Median : 1.000   Median : 1.000  
##  Mean   : 5.654   Mean   : 1.967   Mean   : 2.242   Mean   : 1.445  
##  3rd Qu.: 7.000   3rd Qu.: 2.000   3rd Qu.: 3.000   3rd Qu.: 2.000  
##  Max.   :45.000   Max.   :23.000   Max.   :13.000   Max.   :11.000  
##   match_played   
##  Min.   : 1.000  
##  1st Qu.: 4.000  
##  Median : 6.000  
##  Mean   : 5.749  
##  3rd Qu.: 7.000  
##  Max.   :13.000
mydata$accuracy <- with(mydata, on_target / total_attempts * 100)
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
team_accuracy <- mydata %>%
  group_by(club) %>%
  summarise(AverageAccuracy = mean(accuracy, na.rm = TRUE))
library(ggplot2)

ggplot(team_accuracy, aes(x = reorder(club, -AverageAccuracy), y = AverageAccuracy)) +
  geom_bar(stat = "identity", fill = "steelblue") +
  theme_minimal() +
  labs(title = "Average Shooting Accuracy by Team",
       x = "Team",
       y = "Average Accuracy (%)") +
  coord_flip() 

The analyzis show us that Man. United leads with the highest average accuracy at around 48%.