[英]Is it possible to get notified when a package is loaded within another package or function?
I am writing a function for my package, and its goal is to get notified when a certain package is loaded so that it could do something to respond to the package loading. 我正在为我的程序包编写一个函数,其目的是在加载某个程序包时得到通知,以便它可以对程序包的加载做出响应。 It's similar to
.onLoad()
except that it's the response for other packages. 它与
.onLoad()
相似,只是它是对其他软件包的响应。
Is it possible to do this in R? 在R中可以这样做吗?
OK, I figured it out by using setHook()
. 好的,我通过使用
setHook()
弄清楚了。
setHook(packageEvent("pkg", "attach"),
function(...) {
message('hooked')
} )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.