[R] problem with showMethods()

Day, Roger S day01 at pitt.edu
Sat Sep 21 22:41:30 CEST 2013


This message could be useful for people fairly new to S4 classes.
Therefore r-help and not r-devel.

One use for showMethods(), important to me,
is to find all methods that use a particular class in their signatures.

This works:
	showMethods(class="Action", where="package:CTDesignExplorer")  
It finds the methods in the package.

This works:
	showMethods(class="Action", where=topenv(parent.frame())) 
in the sense that it finds nothing (looking in .GlobalEnv).
	"no applicable functions"

The default for "where" is where=topenv(parent.frame()),
so you'd think this would also give nothing.
	showMethods(class="Action") 
Instead, it prints names of hundreds of S4 generics,  reporting that they are not.
For example, 
	Function "xvcopy":
	 <not an S4 generic function>
that come from packages installed even though they are not loaded.
Since this was the first thing I tried,
getting to the bottom of it derailed me for hours.

The problem seems to be from this, in the definition of showMethod:
	  if (length(f) == 0L) {
	    f <- if (missing(.where))  ### This is the problem. It's missing, even though the default value is set.
	      getGenerics()
	    else getGenerics(.where)
	  }
I think better would be just
	    f <- getGenerics(.where)    
Then the default value would apply.
This would forestall a vast downpour of reports about generics claiming that they are not generics.
Or maybe someone can explain the thinking behind the if clause.

Thanks.

-Roger Day


> sessionInfo()
R version 3.0.1 (2013-05-16)
Platform: x86_64-apple-darwin10.8.0 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] CTDesignExplorer_1.3.9

loaded via a namespace (and not attached):
[1] BiocGenerics_0.6.0 Biostrings_2.28.0  grid_3.0.1         IRanges_1.18.1    
[5] lattice_0.20-15    parallel_3.0.1     stats4_3.0.1       tools_3.0.1  



More information about the R-help mailing list