[R] missing value where TRUE/FALSE needed

From: Peter Lauren <peterdlauren_at_yahoo.com>
Date: Wed 14 Jun 2006 - 05:19:42 EST

I am using R 2.3.0 and trying to run the following code.

	BinMatrix=matrix(nrow=BinCnt, ncol=2)
	for (i in 2:BinCnt)

BinMatrix[i,1]=BinMatrix[i-1,2] BinMatrix[i,2]=BinMatrix[i,2]+Increment } # Count entries in each bin Histogram=vector(length=BinCnt, mode="numeric") for (i in 1:BinCnt) Histogram[i]=0 VectorLength=length(FormerVector) for (i in 1:VectorLength)
Value=FormerVector[i] for (j in 1:BinCnt) if (Value>=BinMatrix[j,1] && Value<=BinMatrix[j,2]) { Histogram[j]=Histogram[j]+1 break; } }

Unfotunately, at
if (Value>=BinMatrix[j,1] && Value<=BinMatrix[j,2]) I get the following error message
Error in if (Value >= BinMatrix[j, 1] && Value <= BinMatrix[j, 2]) { :

        missing value where TRUE/FALSE needed I inserted browser() just before the call and (Value>=BinMatrix[j,1] && Value<=BinMatrix[j,2]) returned FALSE.

Is there a bug in my code or a bug in my version of R?

Many thanks in advance,

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed Jun 14 05:22:13 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 14 Jun 2006 - 18:12:18 EST.

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