s-news
[Top] [All Lists]

Re: locate text in function(s)

To: Kamil Toth <kamiltoth@yahoo.com>
Subject: Re: locate text in function(s)
From: carr.gj@pg.com
Date: Wed, 7 Dec 2005 16:02:09 -0500
Cc: "s-news@lists.biostat.wustl.edu" <s-news@lists.biostat.wustl.edu>
Pgsenderhost: bdc-notes041.na.pg.com [155.125.116.41]

I may be among the "smart people":

functionString<-function(candidates,string){
        ###candidates is character vector (names of objects)
        ###string is text to be matched (regular _expression_)
        results<-logical(length(candidates))
        for (i in seq(along=candidates)){
                if (is.function(get(candidates[i]))){
                        if (any(regexpr(string,deparse(get(candidates[i])))>0)) results[i]<-T
                }
        }
        candidates[results]
}

##example (checks all objects in first pos of search list)
functionString(objects(),string="data\\.frame")




Kamil Toth <kamiltoth@yahoo.com>
Sent by: s-news-owner@lists.biostat.wustl.edu

12/07/2005 02:23 PM

       
        To:        "s-news@lists.biostat.wustl.edu" <s-news@lists.biostat.wustl.edu>
        cc:        
        Subject:        [S] locate text in function(s)



Folks:
Suppose that I have several hundred functions in one project, and I need to quickly locate which of them contains a specific text, say "my.SPLINE". Is there any regular way of doing this? If not, what would you, smart people, do to fulfil this task?
Thanks
Kamil Toth
 


Yahoo! Personals
Let fate take it's course directly to your email.
See who's waiting for you
Yahoo! Personals

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