From a311876@fmr.com  Mon Aug 26 16:30:21 2002
From: a311876@fmr.com (a311876@fmr.com)
Date: Mon, 26 Aug 2002 17:30:21 +0200 (MET DST)
Subject: Rprof and setMethod conflict (PR#1949)
Message-ID: <200208261530.RAA07795@pubhealth.ku.dk>

Full_Name: Kevin C. Bartz
Version: 1.5.1
OS: Solaris 2.6
Submission from: (NULL) (192.223.226.5)


A while ago, I noticed this oddity about R profiling and setMethod.

First, I "test out" Rprof.

> require(methods)
Loading required package: methods 
[1] TRUE
> 
> Rprof("test.out")
> data.frame("a")
  X.a.
1    a
> Rprof(NULL)

So far, so good. Next, I define myClass.

> setClass("myClass", representation(mySlot = "numeric"))
[1] "myClass"
> setMethod("as.data.frame", signature(x = "myClass"),
+           function(x, row.names, optional) { "as.data.frame for myClass" })
Creating a new generic function for "as.data.frame" on 
element 1 of the search path 
[1] "as.data.frame"

Again, everything is fine. I've expanded as.data.frame to accept objects of
class myClass. Now, let's try the standard data.frame("a") again:

> data.frame("a")
  X.a.
1    a

Still, no problems. But after I start R profiling, problems arise:

> Rprof("test2.out")
> data.frame("a")
Error in standardGeneric("as.data.frame") : 
	UseMethod used in an inappropriate fashion

It seems that I can no longer use the standard method for as.data.frame in an R
profiling sequence once I've defined a new method for it. However, I CAN use the
standard as.data.frame method when I'm NOT R profiling.

I know I've brought this up before, but I thought it was appropriate also to log
this bug in a more formal manner.

Thanks,

Kevin

> R.version
         _                   
platform sparc-sun-solaris2.6
arch     sparc               
os       solaris2.6          
system   sparc, solaris2.6   
status                       
major    1                   
minor    5.1                 
year     2002                
month    06                  
day      17                  
language R                   


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


Rprof and setMethod conflict (PR#1949)
a311876@fmr.com