Skip to content
Prev 44595 / 398506 Next

piece wise application of functions

Itay  -

If it were my problem, I would re-structure the task around the
existing capabilities of  lapply().  In particular, I would
concatenate the three lists of functions, then write a wrapper
function which takes three arguments:  an index, a list of
functions and a data set.  Then I would call  lapply()  twice
to get the result you appear to be asking for.  Here's a rough
example, untested, which may not work exactly for your situation.

miss.all <- c(missgp0, missgp1, missgp2)
wrapper  <- function(i, ff, d)  {ff[[i]](d)}
result.1 <- unlist(lapply(seq(9), wrapper, miss.all, snps.missgp[["ic"]]))
result.2 <- unlist(lapply(seq(9), wrapper, miss.all, strs.missgp[["ic"]]))
gaps     <- c(  #  nine multiples of 1e+6 which describe the nine functions )
result   <- cbind(gaps=gaps, snps=result.1, strs=result.2)

In this case,  result  is a matrix, not a data frame, but you can
easily convert between the two.

HTH  -  tom blackwell  -  u michigan medical school  -  ann arbor  -
On Thu, 19 Feb 2004, Itay Furman wrote: