Skip to content

Commit

Permalink
empty names
Browse files Browse the repository at this point in the history
  • Loading branch information
JackStat committed Sep 18, 2015
1 parent 8d25863 commit 8364df5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions R/ParseRush.R
Expand Up @@ -34,7 +34,7 @@ ParseRush <- function(x){
# - Style 1
regParse =
paste0(
"([0-9]{0,4}-[A-Z]\\.[A-Za-z\\'\\-]{1,20}) "
"([0-9]{0,4}-[A-Z]\\.[A-Za-z\\'\\-]{1,20} |)"
,'(runs ob at|runs to|scrambles to|to|pushed ob|pushed ob at|scrambles, runs ob at|sacked at|scrambles, pushed ob at) '
,'([A-Z]{2,6}) ([0-9]{1,3}) '
,'(for) (-|)([0-9]{1,3}) '
Expand All @@ -45,7 +45,7 @@ ParseRush <- function(x){

excludes = 'complete|kicks|Penalty|punts|FUMBLES|penalty'
Cond <- grepl(regParse, textMod) & !grepl(excludes, textMod)
x$Rusher[Cond] = gsub(regParse, '\\1', textMod[Cond])
x$Rusher[Cond] = trim(gsub(regParse, '\\1', textMod[Cond]))

x$RushAtt[Cond] = TRUE
x$RushYards[Cond] = gsub(regParse, '\\6\\7', textMod[Cond])
Expand Down
4 changes: 3 additions & 1 deletion tests/testthat/test_ParseRush.R
Expand Up @@ -36,6 +36,7 @@ TestFrame <- data.frame(
,"15-D.Prescott spikes the ball at LSU 29 for 0 yards."
,"-F.Anderson to TXST 46 for 1 yard."
,"kneels at ORE 48 for -2 yards."
,"to UMASS 28 for -14 yards."
)
)

Expand All @@ -46,7 +47,7 @@ test_that("Rushing Attempts are correctly parsing", {

expect_true(all(Rushes$RushAtt))
expect_equal(Rushes$RushYards,
c(6,-15,6,-15,1,1,1,1,-15,15,0,0,0,0,-15,15,15,5,8,2,2,8,0,-1,-10,1,12,-4,-2, 53,4, 0, 1, -2))
c(6,-15,6,-15,1,1,1,1,-15,15,0,0,0,0,-15,15,15,5,8,2,2,8,0,-1,-10,1,12,-4,-2, 53,4, 0, 1, -2, -14))
expect_true(all(Rushes$Rusher ==
c("15-E.McGuire"
,"8-T.Broadway"
Expand Down Expand Up @@ -82,6 +83,7 @@ test_that("Rushing Attempts are correctly parsing", {
,"15-D.Prescott"
,"-F.Anderson"
,""
,""
)))

})

0 comments on commit 8364df5

Please sign in to comment.