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

Print issue of roc-class object when a formula object is used for creating roc. #101

Closed
NielsKrarup opened this issue Dec 28, 2021 · 4 comments
Labels
bug No, it's not a feature!

Comments

@NielsKrarup
Copy link

Describe the bug
If one programmatically creates formulas using stats::formula or as.formula, when using this in roc(formula=) argument, a print is not able of the resulting roc object.

It seems that this has to do with some non standard evaluation of the argument formula. which is triggered in the method print.dataline() see below rep.ex

To Reproduce
set.seed(123)
df <- data.frame(y = rnorm(10), aval = sample(c(TRUE, FALSE), 10, replace = T))
form <- as.formula("aval ~ y")
roc.obj <- pROC::roc(formula = form, data = df)
print(roc.obj)

#where it fails in print.dataline()
x <- roc.obj
predictor.name <- attr(terms(as.formula(x$call$formula),
data = x$data), "term.labels")

@xrobin xrobin added the bug No, it's not a feature! label Dec 28, 2021
@xrobin
Copy link
Owner

xrobin commented Dec 28, 2021

Thanks for the report and the reproducible example. Indeed because the formula is passed as a variable name it seems to be breaking the terms call in print.dataline.
I'm not entirely sure how to best fix it at this point. I'll give it some more thought to do it properly.

@xrobin
Copy link
Owner

xrobin commented Jan 2, 2022

I investigated a fix where I would make the print function better at getting the data from the global environment.

But I'm running into trouble with stuff like

form <- as.formula("aval ~ y")
with(df, roc(form))

where the data is gone from the environment by the time print is called.

I'm getting all the data for print.dataline when I build the roc object within the roc function, so the proper fix will be to save it in the object. It will however require a major version release, as the objects will be incompatible.

@NielsKrarup
Copy link
Author

NielsKrarup commented Jan 2, 2022 via email

xrobin added a commit that referenced this issue Jul 16, 2022
xrobin added a commit that referenced this issue Jul 16, 2022
xrobin added a commit that referenced this issue Jul 16, 2022
@xrobin
Copy link
Owner

xrobin commented Jul 16, 2022

This should be fixed on master now, and will be included in the next release.
I still need to investigate the issue with the with case - might need an other issue.

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

2 participants