Hi thanoon, Well, you have generated a one column matrix of missing values (NA) and then tried to use those values in a logical test...
Jim On Wed, Nov 4, 2015 at 8:02 PM, thanoon younis <thanoon.youni...@gmail.com> wrote: > Dear R-Users > > After correct some errors in the code below i have only this error > > "Error in if (BZ[i] < 0.25) { : missing value where TRUE/FALSE needed" > > how can i solve this problem please? > > > > N<-200;P<-9 #Sample size > BZ=matrix(NA, nrow=N, ncol=1) > > > W=matrix(NA, nrow=N, ncol=1) > > > for (t in 1:100) { > #Generate the data for the simulation study > for (i in 1:N) { > > #transform theta to ordered categorical variables > > > for(j in 1:1){ > if(BZ[i] < 0.25){ > W[i] = 1 > }else if(BZ[i] >=0.25 & BZ[i] < 0.5){ > W[i] = 2 > }else if(BZ[i] >=0.5 & BZ[i] < 0.75){ > W[i] = 3 > }else{ > W[i] = 4 > }}}} > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.