简体   繁体   中英

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.

Is it possible to do this in R?

OK, I figured it out by using setHook() .

setHook(packageEvent("pkg", "attach"),
    function(...) {
      message('hooked')
    } )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM