s-news
[Top] [All Lists]

Re: R to S conversion of lexical scoping function

To: <s-news@lists.biostat.wustl.edu>
Subject: Re: R to S conversion of lexical scoping function
From: "Joshua Betcher" <jb7gv@virginia.edu>
Date: Fri, 10 May 2002 10:36:21 -0400
Bill Dunlap Wrote:

    Using sys.parent() might be the easiest way here.  However another way
is
    to use substitute():

    fc <- substitute(function(y)f.fc(x,y), list(f.fc=f))

    The function this creates looks odd, e.g, for f<-function(x,y)x/y, fc is

    fc <- function(y) (function(x, y) x/y)(x, y)

    but fc calls the value of f, not f itself.


Another answer, which is less general, Josh Betcher found to be:
     fc <- function(x=NULL,y=NULL,f)  f(x,y)

    apply(exprs(object), 1, fc, f = f, x = object@phenoData@pData[[covlab]])



Thanks for everyones help,
Josh




<Prev in Thread] Current Thread [Next in Thread>