Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Keisuke ANDO
socceR
Commits
00c21976
Commit
00c21976
authored
Dec 06, 2022
by
Keisuke ANDO
😌
Browse files
Merge branch 'foul-detection' into 'develop'
organize branches See merge request
!3
parents
a41ea179
5c00067c
Changes
1
Hide whitespace changes
Inline
Side-by-side
R/detect_foul.R
0 → 100644
View file @
00c21976
detect_foul
<-
function
(
path
)
{
rcl
<-
path
|>
readr
::
read_lines
()
foul_actions
<-
c
()
count
<-
1
for
(
i
in
rcl
)
{
str
<-
stringr
::
str_extract
(
i
,
"foul_\\w+_(l|r)"
)
if
(
!
is.na
(
str
))
{
foul_actions
<-
c
(
foul_actions
,
rcl
[
count
-
1
])
}
count
<-
count
+
1
}
foul_actions
<-
foul_actions
|>
tibble
::
as_tibble
()
|>
dplyr
::
mutate
(
step
=
value
|>
stringr
::
str_extract
(
"\\d+"
)
|>
as.numeric
(),
agent
=
value
|>
stringr
::
str_extract
(
"\\w+_([0-9]{1,2}|Coach)"
),
team
=
agent
|>
stringr
::
str_remove
(
"_([0-9]{1,2}|Coach)"
),
unum
=
agent
|>
stringr
::
str_extract
(
"([0-9]{1,2}|Coach)$"
),
commands
=
value
|>
stringr
::
str_extract
(
"\\(.+\\)$"
)
|>
purrr
::
map
(
~
.x
|>
stringr
::
str_split
(
"\\(|\\)"
,
simplify
=
TRUE
)
|>
stringr
::
str_trim
()
|>
purrr
::
discard
(
~
.x
==
""
)),
)
|>
tidyr
::
unnest
(
commands
)
|>
dplyr
::
mutate
(
commands
=
commands
|>
stringr
::
str_split
(
"\\ "
,
n
=
2
),
command
=
commands
|>
purrr
::
map_chr
(
1
),
args
=
commands
|>
purrr
::
map
(
~
.x
[
-1
]),
)
|>
dplyr
::
select
(
step
,
team
,
unum
,
command
,
args
,
# line = value,
)
|>
dplyr
::
filter
(
command
==
"tackle"
)
return
(
foul_actions
)
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment