Re: [R] Referencing function name from within function

From: <>
Date: Tue 03 Apr 2007 - 11:40:25 GMT

I dunno much about such things, but a wee experiment seems to indicate that the following structure does what you want:

        myfunction <- function(x){
                nm <- as.character([1]
                a  <- TRUE
                if (a){
                        stop(paste(nm,"requires xyz!"))


                                        Rolf Turner

===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+=== Original message:

> For verbose coding I'd like to do something like:
> > myfunction <- function(x){
> > if (a){
> > stop(paste(myfunction_name_here,"requires xyz!")
> > }
> Is that possible?

        (Note: In R *all* things are possible!) mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Tue Apr 03 21:46:18 2007

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 Tue 03 Apr 2007 - 13:30:43 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.