Commit 9b7e41c4 authored by Takumi Amano's avatar Takumi Amano 💬
Browse files

[add] シュートに関するデータの作成

parent 3a4dc41e
...@@ -182,6 +182,16 @@ get_dribble_Allplayer <- function(players, dribble) { ...@@ -182,6 +182,16 @@ get_dribble_Allplayer <- function(players, dribble) {
return(output) return(output)
} }
get_shoot_Allplayer <- function(players, shoot) {
shoot <- shoot %>%
dplyr::select(step,shoot_team = team,ball_x,ball_y,ball_vx,ball_vy,next_ball_x,next_ball_y,next_ball_vx,next_ball_vy,shoot,shoot_scc,ball_goal_dist,ball_goal_angle)
output <- players %>%
dplyr::inner_join(shoot, by = "step") %>%
dplyr::distinct(step,team,unum, .keep_all = TRUE)%>%
dplyr::mutate(ball_player_dist = sqrt((px-ball_x)^2+(py-ball_y)^2))
return(output)
}
get_pass <- function(kick) { get_pass <- function(kick) {
output <- kick |> output <- kick |>
dplyr::filter(pass == TRUE) %>% dplyr::filter(pass == TRUE) %>%
...@@ -200,6 +210,16 @@ get_dribble <- function(kick) { ...@@ -200,6 +210,16 @@ get_dribble <- function(kick) {
return(output) return(output)
} }
get_shoot <- function(kick) {
output <- kick %>%
dplyr::filter(shoot == TRUE) %>%
distinct(step, .keep_all = TRUE) %>%
dplyr::select(step,team,unum,px,py,pvx,pvy,ball_x,ball_y,ball_vx,ball_vy,next_ball_x,next_ball_y,next_ball_vx,next_ball_vy,shoot,shoot_scc) %>%
dplyr::mutate(ball_goal_dist = sqrt((54-abs(ball_x))^2+abs((ball_y))^2)) %>%
dplyr::mutate(ball_goal_angle = atan2((54-abs(ball_x)),ball_y))
return(output)
}
get_dp <- function(dribbleAll){ get_dp <- function(dribbleAll){
output <- dribbleAll |> output <- dribbleAll |>
dplyr::mutate(p_speed = sqrt(pvx^2 + pvy^2)) %>% dplyr::mutate(p_speed = sqrt(pvx^2 + pvy^2)) %>%
...@@ -208,6 +228,49 @@ get_dp <- function(dribbleAll){ ...@@ -208,6 +228,49 @@ get_dp <- function(dribbleAll){
return(output) return(output)
} }
get_as <- function(kick){
output <- kick |>
dplyr::select(step,action_team=team,shoot,dribble,pass)
return(output)
}
get_goalkeeper_action<- function(actionAll){
output <- actionAll |>
dplyr::filter(unum == 1) %>%
dplyr::mutate(ball_keeper_dist_x = sqrt((px-ball_x)^2)) %>%
dplyr::mutate(player_goal_dist = sqrt((54-abs(px))^2+abs((py))^2)) %>%
dplyr::mutate(opp_team =(team != shoot_team)) %>%
dplyr::mutate(ball_closer_goal_goalkeeper = opp_team & (ball_goal_dist < player_goal_dist))
return(output)
}
get_shoot_epv <- function(players,shoot){
shootAll <- get_shoot_Allplayer(players,shoot)
goalkeeper <- get_goalkeeper_action(shootAll) |>
dplyr::filter(team != shoot_team) |>
dplyr::select(step,ball_keeper_dist_x,keeper_goal_dist=player_goal_dist,ball_closer_goal_goalkeeper)
opponent_team <- shootAll |>
dplyr::filter(team != shoot_team) %>%
dplyr::mutate(r_post_x = (ball_x + (py - ball_y)*(7-ball_x)/(-54-ball_y))) %>%
dplyr::mutate(l_post_x = (ball_x + (py - ball_y)*(-7-ball_x)/(-54-ball_y))) %>%
dplyr::mutate(triangle_in_player = (px > l_post_x)&(px < r_post_x)) %>%
dplyr::mutate(dist_ball_in_3m = (ball_player_dist < 3))
opp_triangle_in_player_num <- opponent_team |>
dplyr::filter(triangle_in_player) %>%
dplyr::group_by(step) %>%
dplyr::summarise(triangle_in_player_num=n())
opp_dist_ball_in_3m_num <- opponent_team |>
dplyr::filter(dist_ball_in_3m) %>%
dplyr::group_by(step) %>%
dplyr::summarise(dist_ball_in_3m_num=n())
output <- shoot |>
dplyr::left_join(goalkeeper,by = "step") %>%
dplyr::left_join(opp_dist_ball_in_3m_num,by="step") %>%
dplyr::left_join(opp_triangle_in_player_num,by = "step")
return(output)
}
before_goal <- function(kick_log, goal_step, goal_team) { before_goal <- function(kick_log, goal_step, goal_team) {
playlist <- kick_log %>% playlist <- kick_log %>%
dplyr::arrange(desc(step)) %>% dplyr::arrange(desc(step)) %>%
...@@ -287,6 +350,7 @@ get_name <- function(path_rcg) { ...@@ -287,6 +350,7 @@ get_name <- function(path_rcg) {
replase_rcg_to_rcl <- function(path_rcg) { replase_rcg_to_rcl <- function(path_rcg) {
output <- path_rcg |> stringr::str_replace(pattern = ".rcg", replacement = ".rcl") output <- path_rcg |> stringr::str_replace(pattern = ".rcg", replacement = ".rcl")
} }
replase_rcl_to_rcg <- function(path_rcl) { replase_rcl_to_rcg <- function(path_rcl) {
output <- path_rcl |> stringr::str_replace(pattern = ".rcl", replacement = ".rcg") output <- path_rcl |> stringr::str_replace(pattern = ".rcl", replacement = ".rcg")
} }
...@@ -376,6 +440,7 @@ get_DynamicPressureLine_D <- function(dribble) { ...@@ -376,6 +440,7 @@ get_DynamicPressureLine_D <- function(dribble) {
dplyr::select(step,AL,ML,DL) dplyr::select(step,AL,ML,DL)
return(output) return(output)
} }
add_DynamicPressureLine <- function(action_All,name){ add_DynamicPressureLine <- function(action_All,name){
action_l <- select_name(action_All,name[1,2]) action_l <- select_name(action_All,name[1,2])
action_r <- select_name(action_All,name[2,2]) action_r <- select_name(action_All,name[2,2])
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment