[R] result NA , but expected True or False

David Winsemius dwinsemius at comcast.net
Mon Aug 10 08:32:00 CEST 2015


On Aug 9, 2015, at 8:45 PM, Ragia Ibrahim wrote:

> Dear Group,
> Kindly,
> 
> I have those two lines
> if(  (z_nebla==0) ||  (z_nebla_dash==0) )
>           CM <- 0         else             
> 
>               CM <-  0.5 *(1/a)  +   0.5*(1/b)  
> 
> when running it
> 
> I got this
> 
> z_nebla==0)
> logical(0)
>> (z_nebla_dash==0)
> logical(0)
>> (z_nebla==0) ||  (z_nebla_dash==0)
> [1] NA
> 
> 
> why  (z_nebla==0) ||  (z_nebla_dash==0)
> gives me NA ?

We should instead ask you: why should a logical-OR give anything other than NA when given two length-zero vectors as arguments?

 What value do you expect?

> 
> thanks in advance
> Ragia
> 
> 		 	   		  
> 	[[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 guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius
Alameda, CA, USA



More information about the R-help mailing list