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:
>
> Dear all,
>
> After struggling for some time with *apply() and eva() without
> success, I decided to ask for help.
>
> I have 3 lists labeled with, each contains 3 different
> interpolation functions with identical names:
>
> > names(missgp0)
> [1] "spl.1mb" "spl.2mb" "spl.5mb"
> >
> > names(missgp1)
> [1] "spl.1mb" "spl.2mb" "spl.5mb"
> >
> > names(missgp2)
> [1] "spl.1mb" "spl.2mb" "spl.5mb"
> >
>
> (
> In case it matters the functions accept and return one argument:
> block.size <- spl.1mb(ic)
> )
>
> Then, I have 2 data frames with identical structure:
>
> > snps.missgp
> intvl.mb ic
> 1 1e+06 0.597
> 2 2e+06 0.504
> 3 5e+06 0.327
> 4 1e+07 0.204
> >
>
> > strs.missgp
> intvl.mb ic
> 1 1e+06 0.67200
> 2 2e+06 0.62325
> 3 5e+06 0.51000
> 4 1e+07 0.38775
> >
>
> I would like to apply the functions on these data frames
> piece-wise and create a data frame per function _list_.
>
> So I am looking for a final output like this:
>
> > case0
> gap snps strs
> 1 1e+06 .. ..
> 2 2e+06 .. ..
> 3 5e+06 .. ..
>
> Here, case0$snps[1] is, for example, the result of applying the
> function in missgp0[1] on the entry snps.missgp$ic[1];
> and, case0$strs[1] is the result of applying the same function
> on strs.missgp$ic[1].
>
> Then, I want to repeat the whole thing with missgp1,2 instead
> of missgp0, generating case1,2 data frames.
>
> How should I do it?
>
>
> Thanks in advance,
> Itay Furman
>
> --------------------------------------------------------------------
> itayf at fhcrc.org Fred Hutchinson Cancer Research Center
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
>