Dear all,

I have something about function outer() that I can't understand. Just see the following example. The two NaNs are due to 0/0, but I can't figure out the cause of the last two errors. I wonder if some one can explain this for me. 
___________________________________________________________________
> sx=rbinom(10,1,0.5);ot=rbinom(10,1,0.5);ag <- rbinom(10,100,0.3);ho <- rbinom(10,100,0.5)
> dp <- function(s,a,h)sum((sx==s)&(ag==a)&(ho==h)&(ot==1))/sum((sx==s)&(ag==a)&(ho==h))
> (function(x,y)dp(1,x,y))(2,3)
[1] NaN
> (function(x,y)dp(0,x,y))(27,52)
[1] NaN
> dpm <- outer(ag,ho,function(x,y)dp(1,x,y))
Error in outer(ag, ho, function(x, y) dp(1, x, y)) : 
 dim<- : dims [product 100] do not match the length of object [1]
> dpf <- outer(ag,ho,function(x,y)dp(0,x,y))
Error in outer(ag, ho, function(x, y) dp(0, x, y)) : 
 dim<- : dims [product 100] do not match the length of object [1]
> 
-------------------------------------------------------------------------------------------------------------------

Thanks very much,
Feng

	[[alternative HTML version deleted]]


