Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execute a function from package after doing library(pkg)

Hi I have a package with a functions that makes a gui with gWidgets, is there a way I can get this to be executed on package load so the interface comes up straight away.

I thought something like this:

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

would work, but I'm still learning about hooks, and the events during package load and unload, and R environment stuff.

EDIT:

This is what I currently have in my zzz file:

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

Thanks,

Ben W.

like image 365
Ward9250 Avatar asked Feb 17 '13 22:02

Ward9250


1 Answers

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

like image 171
Tyler Rinker Avatar answered Oct 11 '22 00:10

Tyler Rinker