[R] piece wise application of functions

Itay Furman itayf at fhcrc.org
Fri Feb 20 00:45:36 CET 2004

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

More information about the R-help mailing list