javed khan
2022-Jan-26 14:04 UTC
[R] Error in if (fraction <= 1) { : missing value where TRUE/FALSE needed
Ivan, thanks When I use options(error = NULL) it says: Error during wrapup: missing value where TRUE/FALSE needed Error: no more error handlers available (recursive errors?); invoking 'abort' restart With traceback(), I get 4: readable_number(max_value - min_value, FALSE) 3: get_nice_ticks(lower_bound, upper_bound) On Wed, Jan 26, 2022 at 2:53 PM Ivan Krylov <krylov.r00t at gmail.com> wrote:> On Wed, 26 Jan 2022 14:47:16 +0100 > javed khan <javedbtk111 at gmail.com> wrote: > > > Error in if (fraction <= 1) { : missing value where TRUE/FALSE needed > > > var <- ifelse(test$operator == 'T14', 1, 0) > > The error must be in a place different from your test$operator > comparison. Have you tried traceback() to get the call stack leading to > the error? Or options(error = recover) to land in a debugger session > the moment an uncaught error happens? (Use options(error = NULL) to go > back to the default behaviour.) > > Unrelated: var <- test$operator == 'T14' will also give you an > equivalent logical vector with a bit less work. > > -- > Best regards, > Ivan >[[alternative HTML version deleted]]
PIKAL Petr
2022-Jan-26 14:29 UTC
[R] Error in if (fraction <= 1) { : missing value where TRUE/FALSE needed
Hi It seems that you are hiding what you really do. This> options(error = NULL)works fine without any error. So please If you want some reasonable answer post question with data and code which is causing the error. My wild guess is that you have some objects in your environment and you do not know that they are used in you commands. Try to start fresh R session and try to inspect your environment with ls() Cheers Petr> -----Original Message----- > From: R-help <r-help-bounces at r-project.org> On Behalf Of javed khan > Sent: Wednesday, January 26, 2022 3:05 PM > To: Ivan Krylov <krylov.r00t at gmail.com> > Cc: R-help <r-help at r-project.org> > Subject: Re: [R] Error in if (fraction <= 1) { : missing value whereTRUE/FALSE> needed > > Ivan, thanks > > When I use options(error = NULL) > > it says: Error during wrapup: missing value where TRUE/FALSE needed > Error: no more error handlers available (recursive errors?); invoking'abort'> restart > > With traceback(), I get > > 4: readable_number(max_value - min_value, FALSE) > 3: get_nice_ticks(lower_bound, upper_bound) > > On Wed, Jan 26, 2022 at 2:53 PM Ivan Krylov <krylov.r00t at gmail.com> wrote: > > > On Wed, 26 Jan 2022 14:47:16 +0100 > > javed khan <javedbtk111 at gmail.com> wrote: > > > > > Error in if (fraction <= 1) { : missing value where TRUE/FALSE > > > needed > > > > > var <- ifelse(test$operator == 'T14', 1, 0) > > > > The error must be in a place different from your test$operator > > comparison. Have you tried traceback() to get the call stack leading > > to the error? Or options(error = recover) to land in a debugger > > session the moment an uncaught error happens? (Use options(error > > NULL) to go back to the default behaviour.) > > > > Unrelated: var <- test$operator == 'T14' will also give you an > > equivalent logical vector with a bit less work. > > > > -- > > Best regards, > > Ivan > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.
Ivan Krylov
2022-Jan-26 14:36 UTC
[R] Error in if (fraction <= 1) { : missing value where TRUE/FALSE needed
On Wed, 26 Jan 2022 15:04:51 +0100 javed khan <javedbtk111 at gmail.com> wrote:> 4: readable_number(max_value - min_value, FALSE) > 3: get_nice_ticks(lower_bound, upper_bound)A quick search of CRAN code suggests that the error originates in the following code: https://github.com/ModelOriented/fairmodels/blob/073a502fd2210f20f43c9c6b3deb40e520ad7de1/R/helper_functions.R#L362 Use the R debugger (see ?recover, ?debug, ?browser) to find out why `fraction` becomes NA. It could be because lower_bound == upper_bound, or because any of them is NA, or for some other reason. We don't know, but you can find out. -- Best regards, Ivan