[Rd] methods/namespaces/possible bug
Kasper Daniel Hansen
khansen at stat.Berkeley.EDU
Tue Jul 15 20:11:44 CEST 2008
Using
> methods("plot")
[1] plot.Date* plot.HoltWinters* plot.POSIXct*
[4] plot.POSIXlt* plot.TukeyHSD plot.acf*
[7] plot.data.frame* plot.decomposed.ts* plot.default
[10] plot.dendrogram* plot.density plot.ecdf
[13] plot.factor* plot.formula* plot.hclust*
[16] plot.histogram* plot.isoreg* plot.lm
[19] plot.medpolish* plot.mlm plot.ppr*
[22] plot.prcomp* plot.princomp* plot.profile.nls*
[25] plot.spec plot.spec.coherency plot.spec.phase
[28] plot.stepfun plot.stl* plot.table*
[31] plot.ts plot.tskernel*
Non-visible functions are asterisked
I don't see plot.function listed. As I read the man page for methods I
would say that the search is just looking for functions with the right
type of name.
If I define a plot.function in my global workspace, methods("plot")
picks it up
> plot.function = function() {print("blah")}
> methods("plot")
[1] plot.Date* plot.HoltWinters* plot.POSIXct*
[4] plot.POSIXlt* plot.TukeyHSD plot.acf*
[7] plot.data.frame* plot.decomposed.ts* plot.default
[10] plot.dendrogram* plot.density plot.ecdf
[13] plot.factor* plot.formula* plot.function
[16] plot.hclust* plot.histogram* plot.isoreg*
[19] plot.lm plot.medpolish* plot.mlm
[22] plot.ppr* plot.prcomp* plot.princomp*
[25] plot.profile.nls* plot.spec plot.spec.coherency
[28] plot.spec.phase plot.stepfun plot.stl*
[31] plot.table* plot.ts plot.tskernel*
Non-visible functions are asterisked
Based on this, I think that methods("plot") should return
plot.function, so I am almost ready to take the bug word in my mouth.
When I debug the methods function it gets to the line
S3reg <- ls(get(".__S3MethodsTable__.", envir = defenv), pattern =
name)
where it searches the .__S3MethodsTable__. object. Consulting the help
page it seems that this object is part of the namespace functionality.
My guess is that something goes wrong because function is a reserved
word?
Kasper
This has been tested under R-2.7.1 on Mac OS X and under a not too
recent version of R-devel under x86_64. My sessionInfo for the Mac
version is
> sessionInfo()
R version 2.7.1 (2008-06-23)
i386-apple-darwin8.10.1
locale:
en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] tools_2.7.1
More information about the R-devel
mailing list