Re: [R] determining a parent function name

From: Ismail Onur Filiz <onurf_at_su.sabanciuniv.edu>
Date: Thu, 31 May 2007 13:03:41 -0700

Sorry for replying to myself, but:

On Thursday 31 May 2007 12:23:12 Ismail Onur Filiz wrote:
> Hi,
>
> On Wednesday 30 May 2007 14:53:28 Sundar Dorai-Raj wrote:
> > error <- function(...) {
> >    msg <- paste(..., sep = "")
> >    if(!length(msg)) msg <- ""
> >    if(require(tcltk, quiet = TRUE)) {
> >      tt <- tktoplevel()
> >      tkwm.title(tt, "Error")
> >      tkmsg <- tktext(tt, bg = "white")
> >      tkinsert(tkmsg, "end", sprintf("Error in %s: %s", "???", msg))
> >      tkconfigure(tkmsg, state = "disabled", font = "Tahoma 12",
> >                  width = 50, height = 3)
> >      tkpack(tkmsg, side = "bottom", fill = "y")
> >    }
> >    stop(msg)
> > }
>
> as.character(sys.call(-1)[[1]]) works for me.

you can furthermore do:

options(error=error)

and remove the stop(msg) call in the last line of the function. Then your function will become the error handler.

Best...

>
> Best...
>
> ______________________________________________
> R-help_at_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.



R-help_at_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 Thu 31 May 2007 - 20:46:13 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 31 May 2007 - 22:31:32 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.