Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: restrict_derivation() expects the derivation in the global environment #1765

Closed
bundfussr opened this issue Feb 23, 2023 · 2 comments · Fixed by #1879
Closed

Bug: restrict_derivation() expects the derivation in the global environment #1765

bundfussr opened this issue Feb 23, 2023 · 2 comments · Fixed by #1879
Assignees
Labels
bug Something isn't working programming

Comments

@bundfussr
Copy link
Collaborator

What happened?

If the function specified for the derivation argument is not in the global environment, restrict_derivation() fails

Session Information

No response

Reproducible Example

derive_var_x <- function(dataset) {
  my_derivation <- function(dataset, new_var) {
    mutate(
      dataset,
      !!enexpr(new_var) := 42
    )
  }

  restrict_derivation(
    dataset,
    derivation = my_derivation,
    args = params(
      new_var = X
    ),
    filter = PARAMCD == "A"
  )
}

my_data <- tibble::tribble(
  ~PARAMCD,
  "A",
  "B"
)

derive_var_x(my_data)
@tomratford
Copy link
Contributor

Hi, I have looked into this and think I have a solution. The issue actually is in match.fun() in the assertion in admiraldev. https://github.com/pharmaverse/admiraldev/blob/main/R/assertions.R#L1038.

I have also added a test case to restrict_derivation to check for this

@tomratford
Copy link
Contributor

see pharmaverse/admiraldev#244 for pr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working programming
3 participants