[R] Summing functions of lists

2010-11-13 Thread Hiba Baroud
Hi I'm trying to sum functions of lists with different lengths. Here is a simplified example of the problem: r=list(1:3,1:5,1:2) r [[1]] [1] 1 2 3 [[2]] [1] 1 2 3 4 5 [[3]] [1] 1 2 x=function(i,j) sum(j*r[[i]])# x is a function of two parameters: i j

Re: [R] Summing functions of lists

2010-11-13 Thread Phil Spector
Does this version of y do what you want? y=function(j)sum(sapply(1:3,function(i)x(i,j))) - Phil Spector Statistical Computing Facility Department of Statistics