Skip to content

Commit

Permalink
extend to do.call case with func param as text (resolves #302) (#309)
Browse files Browse the repository at this point in the history
  • Loading branch information
bburns632 authored Apr 11, 2024
1 parent d2c3c68 commit e2ba8f5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# pkgnet (dev)
## NEW FEATURES
* `do.call` with the function argument as string will now properly appear on the function reporter. Previously, this would show as a `do.call` node with a circular reference. (#302)

## CHANGES

Expand Down
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 e2ba8f5

Please sign in to comment.