Skip to content

Commit

Permalink
extend to do.call case with func param as text
Browse files Browse the repository at this point in the history
  • Loading branch information
bburns632 committed Apr 10, 2024
1 parent a904eca commit e00b5e6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions R/FunctionReporter.R
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,14 @@ FunctionReporter <- R6::R6Class(


if (listable){

# If do.call and first argument is string (atomic), covert to call
if (length(x) >= 2){
if (deparse(x[[1]]) == "do.call" & is.character(x[[2]])){
x[[2]] <- parse(text=x[[2]])
}
}

# Filter out atomic values because we don't care about them
x <- Filter(f = Negate(is.atomic), x = x)

Expand Down
3 changes: 2 additions & 1 deletion inst/baseballstats/R/batting_statistics.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ slugging_avg <- function(outcomes){
4 * sum(outcomes == 'hr')
}

return(bases_on_hits / at_bats(outcomes))
denom <- do.call("at_bats", outcomes)
return(bases_on_hits / denom)
}


Expand Down

0 comments on commit e00b5e6

Please sign in to comment.