r-gregmisc / gtools

Functions to assist in R programming
25 stars 6 forks source link

Very rare issue in quantcut #22

Open simon-lowe opened 4 months ago

simon-lowe commented 4 months ago

In quantcut I am very rarely getting the following error message:

Error in if (pairs[1, i] == pairs[1, i - 1] && pairs[1, i] == pairs[2, : missing value where TRUE/FALSE needed

Because it is happening inside a function running over random draws I don't have a reproducible example. The quantcut call is the following: quantcut(pred_p, q = n_groups, labels = FALSE)

Looking at the source code, I can't actually figure what the issue is. Any ideas?

Thanks!

bbolker commented 3 months ago

I often derive reproducible examples from random examples by doing something like this:

last <- 0
for (i in 1:10000) {
   last <- i
   set.seed(i)
   [try the desired code]
}

The code will stop when the error happens and you should then be able to set.seed(last) and reproduce it ...