Re: [R] srt --- slope text with function? (list user defined functions)

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Mon 06 Feb 2006 - 18:30:15 EST

On Sun, 5 Feb 2006, Pierre Kleiber wrote:

> I'll respond to one of your multitude of queries below. Suggest that you
> confine your postings to a single issue so that the subject heading is more
> meaningful.
>
> Cheers, Pierre
>
>
> ivo welch offered the following remark on 02/05/06 11:28...
> [...]
>>
>> * is there a way to print all my user defined functions? I have an
>> init file, in which I am defining all sorts of useful utility
>> functions, and I would like to print what I have defined (for memory)
>> upon a read of this init file? that is, something that has
>> functionality like
>> note.all.local.definitions.now.in.vector( all.local.functions )
>> a <- function() { }
>> b <- function() { }
>> cat( all.local.functions ); # should print 'a' and 'b'.
>
> The following lists the functions defined in a (default current) environment:
>
> "lsf" <- function (pos = 1)
> {
> junk <- ls(pos, all.names = TRUE)
> junk[sapply(junk, function(x) is.function(eval(as.symbol(x))))]
> }

I am sorry, it does not in general (since eval is not looking in that environment). See ls.str (in utils) for a more elegant way to do this via exists(mode = "function")

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Mon Feb 06 18:40:00 2006

This archive was generated by hypermail 2.1.8 : Tue 07 Feb 2006 - 00:53:19 EST