Thie1e / cutpointr

Optimal cutpoints in R: determining and validating optimal cutpoints in binary classification
https://cran.r-project.org/package=cutpointr
84 stars 13 forks source link

NSE in multi_cutpointr? #15

Closed xrobin closed 5 years ago

xrobin commented 5 years ago

Not a big deal but somewhat surprising, I can do:

cutpointr(suicide, dsi, class=suicide)

but not:

multi_cutpointr(suicide, dsi, class=suicide)
Error in multi_cutpointr(suicide, dsi, class = suicide) : 
  class should be the name of the outcome variable (character)

It would be nice to have NSE for multi_cutpointr too.

xrobin commented 5 years ago

Oh and I see the same behavior for the roc function...

Thie1e commented 5 years ago

Hi, thanks for the suggestion and nice to hear from you. The roc function was designed for optimal speed and thus we didn't add support for NSE. Also, it wasn't exported in earlier versions and only became user-facing later.

I think the help pages describe the use of the functions correctly, but I must agree that the behavior is somewhat inconsistent.

On a more general note: When cutpointr was designed, it wasn't already clear what would be the best way to do NSE and by now it seems that the way the tidyverse is doing it now (with !! and so on) is the way forward. It would be best to eventually deprecate cutpointr_, deprecate the use of quoted arguments in roc and multi_cutpointr (and possibly other functions?) and support the "rlang-way" throughout the package. I have to admit that I had this in mind for a while already, but it would to take some time to rewrite the functions. I'll mark this as an enhancement.

Thie1e commented 5 years ago

As of version 1.0.0 all main functions (cutpointr, multi_cutpointr, and roc) make use of tidyeval, so the arguments can be quoted or unquoted and the !! operator works. Only the x argument of multi_cutpointr stays a character vector. cutpointr_ is deprecated.