[Rd] Rprof/UseMethod

Roger Koenker roger at ysidro.econ.uiuc.edu
Wed Mar 26 04:52:38 MET 2003


I'm having difficulty with Rprof.  I have a documentation example test.qss that
runs fine without profiling, but under Rprof,

> Rprof()
> source("test.qss")
Error in standardGeneric("model.matrix") :
        UseMethod used in an inappropriate fashion

Luke wrote about a similar circumstance last summer:


#   From: Luke Tierney (luke at stat.umn.edu)
#   Date: Fri Jul 19 2002 - 16:03:17 EDT
#
    #   * In reply to: Bartz, Kevin: "[R] Rprof and setMethod conflict?"
#
#   This sounds like a bug in the usemethod code. Profiling adds an extra
#   evaluation context around builtins and that can confuse things that
#   don't take this into account. I unfortunately don't have time to
#   track this properly now, but on a quick glance it looks like changing

        cptr = R_GlobalContext;
        if ( !(cptr->callflag & CTXT_FUNCTION) || cptr->cloenv != env)
            error("UseMethod used in an inappropriate fashion");
#
#   it two places in objects.c to
#
        cptr = R_GlobalContext;
        if (cptr->callflag == CTXT_BUILTIN)
            cptr = cptr->nextcontext;
        if ( !(cptr->callflag & CTXT_FUNCTION) || cptr->cloenv != env)
            error("UseMethod used in an inappropriate fashion");
#
#   might fix this.
#
I tried this,  on my solaris "R version 1.7.0, 2003-02-05" but got complaints
about the use of env from make.  So I quickly retreated.  Any thoughts on this?


url:	www.econ.uiuc.edu	Roger Koenker		Dept. of Economics UCL,
email	rkoenker at uiuc.edu	Department of Economics Drayton House,
vox: 	217-333-4558		University of Illinois	30 Gorden St,
fax:   	217-244-6678		Champaign, IL 61820	London,WC1H 0AX, UK
							vox:	020-7679-5838



More information about the R-devel mailing list