Skip to content
Prev 390575 / 398500 Next

Error in if (fraction <= 1) { : missing value where TRUE/FALSE needed

One could use the microbenchmark package to compare which approach is faster, assuming the dataset is large enough that the outcome will make a measurable difference. 

-----Original Message-----
From: R-help <r-help-bounces at r-project.org> On Behalf Of Bert Gunter
Sent: Thursday, January 27, 2022 10:44 AM
To: PIKAL Petr <petr.pikal at precheza.cz>
Cc: R-help <r-help at r-project.org>
Subject: Re: [R] Error in if (fraction <= 1) { : missing value where TRUE/FALSE needed

[External Email]

This will not help solve the issue, but perhaps it is worth pointing out that the idiom, prot <- ifelse(test$operator == 'T13', 1, 0) is perhaps more simply coded as prot <- test$operator == 'T13'

This will give a logical, TRUE/FALSE, instead of 1/0, but I doubt that a numeric is needed anyway. However, as.numeric() would of course do such a conversion, in which case the original ifelse might as well be used.

Bert Gunter

"The trouble with having an open mind is that people keep coming along and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Wed, Jan 26, 2022 at 11:39 PM PIKAL Petr <petr.pikal at precheza.cz> wrote:
______________________________________________
R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dhelp&d=DwICAg&c=sJ6xIWYx-zLMB3EPkvcnVg&r=9PEhQh2kVeAsRzsn7AkP-g&m=eLthULmcsbsauwFtFwUELWbEcCm6j9dDsFTJTMNM9azTjEAhJ1-qp1QpqM4aMJUU&s=nKOUnbWqTVHBJ8_18UPI_0txX86s35CP6VAqBc-Q6_k&e=
PLEASE do read the posting guide https://urldefense.proofpoint.com/v2/url?u=http-3A__www.R-2Dproject.org_posting-2Dguide.html&d=DwICAg&c=sJ6xIWYx-zLMB3EPkvcnVg&r=9PEhQh2kVeAsRzsn7AkP-g&m=eLthULmcsbsauwFtFwUELWbEcCm6j9dDsFTJTMNM9azTjEAhJ1-qp1QpqM4aMJUU&s=eZti_glRZlkKsUposffe3dMBirNV2J-goX3ARZowxLs&e=
and provide commented, minimal, self-contained, reproducible code.
Message-ID: <BN6PR2201MB155320F2B9CAD66DC5ED486CCF219@BN6PR2201MB1553.namprd22.prod.outlook.com>
In-Reply-To: <CAGxFJbRbyDqqMNq=+7a7_90Kd89+TWp_Br2Ra=uTZOPivTxDQw@mail.gmail.com>

Thread (20 messages)

javed khan Error in if (fraction <= 1) { : missing value where TRUE/FALSE needed Jan 26 Ivan Krylov Error in if (fraction <= 1) { : missing value where TRUE/FALSE needed Jan 26 PIKAL Petr Error in if (fraction <= 1) { : missing value where TRUE/FALSE needed Jan 26 javed khan Error in if (fraction <= 1) { : missing value where TRUE/FALSE needed Jan 26 javed khan Error in if (fraction <= 1) { : missing value where TRUE/FALSE needed Jan 26 PIKAL Petr Error in if (fraction <= 1) { : missing value where TRUE/FALSE needed Jan 26 Ivan Krylov Error in if (fraction <= 1) { : missing value where TRUE/FALSE needed Jan 26 javed khan Error in if (fraction <= 1) { : missing value where TRUE/FALSE needed Jan 26 Jeff Newmiller Error in if (fraction <= 1) { : missing value where TRUE/FALSE needed Jan 26 PIKAL Petr Error in if (fraction <= 1) { : missing value where TRUE/FALSE needed Jan 26 Bert Gunter Error in if (fraction <= 1) { : missing value where TRUE/FALSE needed Jan 27 Ebert,Timothy Aaron Error in if (fraction <= 1) { : missing value where TRUE/FALSE needed Jan 27 javed khan Error in if (fraction <= 1) { : missing value where TRUE/FALSE needed Jan 27 Bert Gunter Error in if (fraction <= 1) { : missing value where TRUE/FALSE needed Jan 27 Bert Gunter Error in if (fraction <= 1) { : missing value where TRUE/FALSE needed Jan 27 javed khan Error in if (fraction <= 1) { : missing value where TRUE/FALSE needed Jan 27 Ebert,Timothy Aaron Error in if (fraction <= 1) { : missing value where TRUE/FALSE needed Jan 27 Avi Gross Error in if (fraction <= 1) { : missing value where TRUE/FALSE needed Jan 27 Avi Gross Error in if (fraction <= 1) { : missing value where TRUE/FALSE needed Jan 27 Ebert,Timothy Aaron Error in if (fraction <= 1) { : missing value where TRUE/FALSE needed Jan 28