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

Cannot create a roc curve with a formula and a with clause #111

Closed
xrobin opened this issue May 6, 2023 · 2 comments
Closed

Cannot create a roc curve with a formula and a with clause #111

xrobin opened this issue May 6, 2023 · 2 comments
Labels
bug No, it's not a feature!

Comments

@xrobin
Copy link
Owner

xrobin commented May 6, 2023

This is a follow-up of #101.

form <- as.formula("outcome ~ wfns")
with(df, roc(form))

Throws an error:

Erreur dans eval(substitute(expr), data, enclos = parent.frame()) : 
  argument 'envir' incorrect de type 'closure'
3: eval(substitute(expr), data, enclos = parent.frame())
2: with.default(df, roc(form))
1: with(df, roc(form))
@xrobin xrobin added the bug No, it's not a feature! label May 6, 2023
@xrobin
Copy link
Owner Author

xrobin commented Aug 1, 2023

Note that this style also doesn't work with standard R functions such as glm:

form <- as.formula("outcome ~ wfns")
with(df, glm(form))

This is because it is the environment of the formula which matters. So that works instead:

form <- with(aSAH, as.formula("age ~ ndka"))
glm(form)

And it works as well with pROC currently:

form <-  with(aSAH, as.formula("outcome ~ wfns"))
roc(form)

xrobin added a commit that referenced this issue Aug 1, 2023
@xrobin
Copy link
Owner Author

xrobin commented Aug 1, 2023

The solution is pretty ugly and may not be optimal, but the combination is now working and tested.

There will probably be edge cases where it doesn't work and the search should be loosened further. However it works in testthat tests.

@xrobin xrobin closed this as completed Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug No, it's not a feature!
Projects
None yet
Development

No branches or pull requests

1 participant