Re: [R] Error .. missing value where TRUE/FALSE needed

From: jim holtman <jholtman_at_gmail.com>
Date: Sun, 6 Jan 2008 08:32:29 -0500

When the error occurs, valueDiff is NA:

Error in if ((seedCount <= seedNumber) && (valueDiff > sup)) { :   missing value where TRUE/FALSE needed
> valueDiff

[1] NA
>

Look at your loop; you are going through 100 times so on the last time you are trying to access: fcsPar[k+1] which is the 101th entry which is NA. Your program has a bug in it.

On Jan 6, 2008 1:22 AM, Nicholas Crosbie <crosbienicholas_at_yahoo.com.au> wrote:
> Can any explain the following error:
>
> Error in if ((seedCount <= seedNumber) && (valueDiff >
> sup)) { :
> missing value where TRUE/FALSE needed
>
> which I get upon running this script:
>
> seedNumber <- 10
> seeds <- array(dim = seedNumber)
> seedCount <- 1
>
> maxValue <- 100
> sup <- maxValue / 2
>
> fcsPar <- array(as.integer(rnorm(100, 50, 10)))
>
> while (seedCount <= seedNumber) {
> for(k in 1:100) {
> valueDiff <- abs(fcsPar[k] - fcsPar[k+1])
> if((seedCount <= seedNumber) && (valueDiff >
> sup)) { #error
> seeds[seedCount] <- fcsPar[k]
> seedCount <- seedCount + 1
> }
> }
> sup <- sup / 2
> }
>
>
> many thanks.
>
>
>
>
> Make the switch to the world's best email. Get the new Yahoo!7 Mail now. www.yahoo7.com.au/worldsbestemail
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Sun 06 Jan 2008 - 13:39:47 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 06 Jan 2008 - 15:30:05 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive