[英]Using R, how to delist a function from a methods namespace such as `S3`?
The plot
functions in R are tied to an S3method
. R 中的
plot
函数与 S3method 相关S3method
。 By default,默认,
> methods("plot")
[1] plot.acf* plot.data.frame* plot.decomposed.ts* plot.default
[5] plot.dendrogram* plot.density* plot.ecdf plot.factor*
[9] plot.formula* plot.function plot.hclust* plot.histogram*
[13] plot.HoltWinters* plot.isoreg* plot.lm* plot.medpolish*
[17] plot.mlm* plot.ppr* plot.prcomp* plot.princomp*
[21] plot.profile.nls* plot.raster* plot.spec* plot.stepfun
[25] plot.stl* plot.table* plot.ts plot.tskernel*
[29] plot.TukeyHSD*
I can manually define a new function at the console:我可以在控制台手动定义一个新的 function :
plot.tukey = function(x) {}
It automatically gets listed in the methods("plot") based on its naming convention:它会根据其命名约定自动列在方法(“绘图”)中:
> methods("plot")
[1] plot.acf* plot.data.frame* plot.decomposed.ts* plot.default
[5] plot.dendrogram* plot.density* plot.ecdf plot.factor*
[9] plot.formula* plot.function plot.hclust* plot.histogram*
[13] plot.HoltWinters* plot.isoreg* plot.lm* plot.medpolish*
[17] plot.mlm* plot.ppr* plot.prcomp* plot.princomp*
[21] plot.profile.nls* plot.raster* plot.spec* plot.stepfun
[25] plot.stl* plot.table* plot.ts plot.tskernel*
[29] plot.tukey plot.TukeyHSD*
see '?methods' for accessing help and source code
delist
or unregister
the function from the default S3
namespace?S3
命名空间中删除或unregister
delist
? That is, I want plot.tukey to be declared a function, but not be attached to the S3
namespace.也就是说,我希望将 plot.tukey 声明为 function,但不附加到
S3
命名空间。 Is there an unUseMethod
functionality?是否有
unUseMethod
功能?
It seems like you are wrestling deep in the bowels of R and your motivation is a desire to define看起来你在 R 的内心深处挣扎,你的动机是想要定义
plot.tukey = function(x) {}
which would show up on a methods("plot")
call rather than say这将出现在
methods("plot")
调用而不是说
plot_tukey = function(x) {}
which would not?哪个不会?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.