问题描述
你好我有一个包含一个函数的函数,它可以使用gWidgets创建一个gui,有没有一种方法可以让它在包加载时执行,因此界面马上就会出现。
我认为是这样的:
.OnAttach< - 函数(libname,pkgname){
gui()
}
,但我仍然在学习钩子,以及包加载和卸载过程中的事件以及R环境的东西。
编辑:
这是我目前在我的zzz文件中所具有的功能:
.onLoad< - function(libname = find.package(GspeEaR),pkgname =GspeEaR){
gui()
}
谢谢,
本W
我想你要的是 .onLoad
,它将转储到名为zzz.R(传统上)的.R文件中。以下是我使用过的示例:
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.
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
这篇关于库(pkg)后执行包中的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!