[R] different functions on different vector subsets

Thomas Lumley tlumley at u.washington.edu
Thu Nov 10 22:02:13 CET 2005


On Thu, 10 Nov 2005, Ron Ophir wrote:

> Thanks Thomas,
>
> "...For logical subscripts you could argue that the
> ambiguity isn't present and that if the index was NA the element should
> just be set to NA. This change might be worth making."
>
> I see you got my point. NA should return NA no matter what the
> comparison is.

I'm not sure that I did get your point.  As Brian said, you aren't 
specifying whether or not to set the value. In your example it didn't 
matter because it would end up NA either way.

I was saying that for eg

a<-c(1,2,3,4)
b<-c(NA,T,F,T)

a[b]<-7

we could relax the prohibition on NA indexing to give c(NA,7,7,7) as the 
result. In your case that would give what you wanted, but in other cases 
it might not.


 	-thomas




More information about the R-help mailing list