[R] srt --- slope text with function? (list user defined functions)
Prof Brian Ripley
ripley at stats.ox.ac.uk
Mon Feb 6 08:30:15 CET 2006
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 at 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
More information about the R-help
mailing list