I think the issue is in the function fr,

?apply
apply returns a vector or array or list of values

So if the inner apply returns a list (this happens when different  
number of elements in y are positive in different rows) then outer  
apply cannot coerce it into the correct format to apply the product
To see this try

set.seed(1)
v<- runif(12, -10,10)
fr(v)

Nikhil

On 19 Nov 2009, at 6:05PM, lloyd barcza wrote:

> fr<-function(x){y<-x*D
> C<-apply(t(apply(y,1,function(c){c[c>0]})),1,prod)
> R2<-R*C
> w<-R2[R2<P]
> g<-sum(w)
> return(g)}


	[[alternative HTML version deleted]]


