harrelfe / rms

Regression Modeling Strategies
https://hbiostat.org/R/rms
Other
172 stars 48 forks source link

cr.setup fails if length of substitute(y) is greater than 1 #102

Open e3bo opened 3 years ago

e3bo commented 3 years ago

Minimal example:

data <- data.frame(y = c(1, 2, 3))
rms::cr.setup(data$y)

produces

Error in factor(cuts, levels = 0:(kint - 1), labels = labels) : 
  invalid 'labels'; length 4 should be 1 or 2

while with(data, rms::cr.setup(y)) works as expected.

Perhaps this should be documented, or a line such as if(length(yname) > 1) yname <- "y" could make the function more robust.