library(tsibble)
## Warning: package 'tsibble' was built under R version 4.3.3
## Registered S3 method overwritten by 'tsibble':
## method from
## as_tibble.grouped_df dplyr
##
## Attaching package: 'tsibble'
## The following objects are masked from 'package:base':
##
## intersect, setdiff, union
library(ggplot2)
library(lubridate)
##
## Attaching package: 'lubridate'
## The following object is masked from 'package:tsibble':
##
## interval
## The following objects are masked from 'package:base':
##
## date, intersect, setdiff, union
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
volley_data <- read.csv("C:\\Users\\brian\\Downloads\\bvb_matches_2022.csv")
kill_data <- volley_data |>
select(w_p1_tot_attacks, w_p1_tot_kills, w_p1_tot_errors) |>
mutate(w_p1_kill_pct = (w_p1_tot_kills - w_p1_tot_errors)/ w_p1_tot_attacks) |>
na.omit(kill_data)
head(kill_data)
## w_p1_tot_attacks w_p1_tot_kills w_p1_tot_errors w_p1_kill_pct
## 1 28 18 5 0.4642857
## 2 23 15 1 0.6086957
## 3 34 21 2 0.5588235
## 4 18 9 4 0.2777778
## 5 25 16 6 0.4000000
## 6 26 15 3 0.4615385
plot(kill_data$w_p1_tot_attacks, kill_data$w_p1_kill_pct,
main = "Total Attacks vs Kill Percentage",
xlab = "Total Attacks",
ylab = "Kill Percentage",
pch = 19, col = "blue")
plot(kill_data$w_p1_tot_kills, kill_data$w_p1_kill_pct,
main = "Total Kills vs Kill Percentage",
xlab = "Total Kills",
ylab = "Kill Percentage",
pch = 19, col = "blue")
plot(kill_data$w_p1_tot_errors, kill_data$w_p1_kill_pct,
main = "Total Errors vs Kill Percentage",
xlab = "Total Errors",
ylab = "Kill Percentage",
pch = 19, col = "blue")
These plots show the relationship between kill percentage and each of the variables that contributes to its calculation. It looks like as total attacks and total errors increases, the average kill percentage decreases. Total kills is averaged between 10-20 with some outliers. Generally as kills increase, we would expect the kill percentage to increase but it does not look like there is a clear trend.
cor_attacks <- cor(kill_data$w_p1_tot_attacks, kill_data$w_p1_kill_pct)
cor_attacks
## [1] -0.3329784
cor_kills <- cor(kill_data$w_p1_tot_kills, kill_data$w_p1_kill_pct)
cor_kills
## [1] 0.1367731
cor_errors <- cor(kill_data$w_p1_tot_errors, kill_data$w_p1_kill_pct)
cor_errors
## [1] -0.6620581
kill_mean <- mean(kill_data$w_p1_kill_pct)
kill_sd <- sd(kill_data$w_p1_kill_pct)
kill_n <- nrow(kill_data)
kill_se <- kill_sd / sqrt(kill_n)
kill_ci <- qt(0.975, df = kill_n - 1)* kill_se
kill_ci_low <- kill_mean - kill_ci
kill_ci_up <- kill_mean + kill_ci
cat("95% Confidence Interval for Kill Percentage : (", kill_ci_low, ", ", kill_ci_up, ")")
## 95% Confidence Interval for Kill Percentage : ( 0.447933 , 0.4738751 )
Based on these calculations, we can conclude that as a player has more attacks or errors, their kill percentage decreases. As a player has more kills, their kill percentage increases. The confidence interval shows that 95% of the time the mean kill percentage will fall within the interval (.447, .473). This is reasonable to assume that on average, winning players will have just under a 50% kill percentage.