Execute a function from a package after executing the library (pkg)

Hi I have a package with functions that gui create with gWidgets, is there a way I can get this to work when the package loads, so the interface appears immediately.

I thought something like this:

.OnAttach <- function(libname, pkgname){ gui() } 

will work, but I still learn about interceptions and events during loading and unloading of the package and material of the R environment.

EDIT:

This is what I have in my zzz file:

 .onLoad <- function(libname = find.package("GspeEaR"), pkgname = "GspeEaR") { gui() } 

Thanks,

Ben W.

+8
function r package load
source share
1 answer

I think you want a .onLoad that you dump in a .R file called zzz.R (traditionally). Here is an example where I used this: github.com/trinker/gmailR/blob/master/R/zzz.R

+3
source share

All Articles