Re: [R] get caller's name

2011-02-04 Thread Luke Tierney
Adrogué Cc: r-h...@stat.math.ethz.ch Subject: Re: [R] get caller's name On 03/02/2011 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") } } Thi

Re: [R] get caller's name

2011-02-04 Thread William Dunlap
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Duncan Murdoch > Sent: Friday, February 04, 2011 6:03 AM > To: Ernest Adrogué > Cc: r-h...@stat.math.ethz.ch > Subject: Re: [R] get caller's name &

Re: [R] get caller's name

2011-02-04 Thread Duncan Murdoch
On 03/02/2011 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") } } This would be used by other functions that can only work with dimensionless objects. The proble

Re: [R] get caller's name

2011-02-03 Thread Ernest Adrogué
3/02/11 @ 14:30 (-0200), Henrique Dallazuanna escriu: > Try this: > > g <- function(.x) tryCatch(stop.if.dims(.x), error=function(e)sprintf("Error > in %s: %s", deparse(sys.call(1)), e$message)) > g(rbind(2, 3)) This is it. Thanks! Cheers. -- Ernest __

Re: [R] get caller's name

2011-02-03 Thread Ernest Adrogué
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 <- m

Re: [R] get caller's name

2011-02-03 Thread Henrique Dallazuanna
Try this: g <- function(.x) tryCatch(stop.if.dims(.x), error=function(e)sprintf("Error in %s: %s", deparse(sys.call(1)), e$message)) g(rbind(2, 3)) 2011/2/3 Ernest Adrogué > Hi, > Suppose a function that checks an object: > > stop.if.dims <- function(x) { > if (! is.null(dim(x))) { >stop(

Re: [R] get caller's name

2011-02-03 Thread David Winsemius
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(substitut

[R] get caller's name

2011-02-03 Thread Ernest Adrogué
Hi, Suppose a function that checks an object: stop.if.dims <- function(x) { if (! is.null(dim(x))) { stop("cannot handle dimensional data") } } This would be used by other functions that can only work with dimensionless objects. The problem is the error message would need to include the n