[R] get caller's name

Ernest Adrogué nfdisco at gmail.com
Thu Feb 3 17:45:39 CET 2011


 3/02/11 @ 11:25 (-0500), David Winsemius escriu:
> On Feb 3, 2011, at 10:27 AM, Ernest Adrogué wrote:
> 
> >Hi,
> >Suppose a function that checks an object:
> >
> >stop.if.dims <- function(x) {
> > if (! is.null(dim(x))) {
> >   stop("cannot handle dimensional data")
> > }
> >}
> >
> 
> > mtx <- matrix(c(1,0,0,1), 2)
> > stop.if.dims <- function(x) { objname <- deparse(substitute(x))
> +  if (! is.null(dim(x))) {
> +    stop(paste(objname,"cannot handle dimensional data") )
> +  }
> + }
> > stop.if.dims(mtx)
> Error in stop.if.dims(mtx) : mtx cannot handle dimensional data

Here, "mtx" is the name of the argument that stop.if.dims gets.
What I want is name of the function that calls stop.if.dims.

That being said, I was also interested in getting the names
of arguments, so thanks :) 

Cheers.
-- 
Ernest



More information about the R-help mailing list