Closed NielsKrarup closed 1 year ago
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.
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.
Dear Robin
Thank you for looking into this - I have used pROC a lot and also did not see any slick way of solving it. Your method sounds like a good solution. Im surprised the issue has not been brought up before, as many must use roc() programmatically, or maybe that is exactly why - since one mainly like to print roc objects for initial exploratory analysis.
Thanks you for taking it up, and for a nice package.
br, Niels
Den søn. 2. jan. 2022 kl. 17.21 skrev Xavier Robin @.***
:
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.
— Reply to this email directly, view it on GitHub https://github.com/xrobin/pROC/issues/101#issuecomment-1003740477, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGHUKJJM463JZV7CPK4DXXTUUB3R5ANCNFSM5K3YA7EQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you authored the thread.Message ID: @.***>
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.
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")