[R] Referencing function name from within function
rolf at math.unb.ca
rolf at math.unb.ca
Tue Apr 3 13:40:25 CEST 2007
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(match.call())[1]
a <- TRUE
if (a){
stop(paste(nm,"requires xyz!"))
}
}
cheers,
Rolf Turner
rolf at math.unb.ca
===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+===
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!)
More information about the R-help
mailing list