There isn't combination of c(1, 1), so is NA:

tapply(y, list(X1, X2), sum)

On Wed, Jan 26, 2011 at 9:04 AM, René Holst <rene@constat.dk> wrote:

> Hello,
>
> I have observed the following odd behavior of "is.na( )" and hope someone
> can give me an explanation
> Example:
> X1=rep(1:2,5)[-1]
> X2=rep(1:5,rep(2,5))[-1]
> y= runif(9)
> y[3]=NA
> xtabs(y~x1+x2)
>
> Now
>
> xtabs(is.na(y)~x1+x2) says that cell 2,2 is NA
>
>   x2
> x1  1 2
>  1 0 0
>  2 0 1
>  3 0 0
>  4 0 0
>  5 0 0
>
> Whereas
>
> xtabs(!is.na(y)~x1+x2) says that all but cell 1,1 and 2,2 are not NA
>   x2
> x1  1 2
>  1 0 1
>  2 1 0
>  3 1 1
>  4 1 1
>  5 1 1
>
> An explanation will be much appriciated
>
> ______________________________________________
> R-help@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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

	[[alternative HTML version deleted]]

