Re: [R] How to get the function names

From: Jerome Asselin <jerome.asselin_at_crchum.qc.ca>
Date: Thu 05 Oct 2006 - 21:07:05 GMT

On Thu, 2006-10-05 at 22:41 +0200, Søren Højsgaard wrote:
> I've defined the function
>
> getFunNames <- function(FUN){
> if (!is.list(FUN))
> fun.names <- paste(deparse(substitute(FUN)), collapse = " ")
> else
> fun.names <- unlist(lapply(substitute(FUN)[-1], function(a) paste(a)))
> fun.names
> }

Hi,

Try this:
> getFunNames <- function(x)

+ sapply(as.list(sys.call()[[2]][-1]),as.character)
> getFunNames(c(mean,ff))
[1] "mean" "ff"
> foo <- function() getFunNames(c(mean,ff))
> foo()

[1] "mean" "ff"

HTH,
Jerome

-- 
Jerome Asselin, M.Sc., Agent de recherche, RHCE
CHUM -- Centre de recherche
3875 rue St-Urbain, 3e etage // Montreal QC  H2W 1V1
Tel.: 514-890-8000 Poste 15914; Fax: 514-412-7106

______________________________________________
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
and provide commented, minimal, self-contained, reproducible code.
Received on Fri Oct 06 08:11:06 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 05 Oct 2006 - 22:30:08 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.