R: How to run some code on load of package?

后端 未结 1 1234
情书的邮戳
情书的邮戳 2020-12-05 06:44

I am learning to build a package for R. Now to set it up I need to run some code when the package is being loaded via require(myPackage).

I read the doc

相关标签:
1条回答
  • 2020-12-05 07:24

    There is usually a "processing function" (traditionally called zzz.R) with tasks to be performed when the package is loaded, such as loading libraries and compiled code. For example you can create a zzz.R file where you create this function:

    .onLoad <- function(libname, pkgname){
      x <- rnorm(10)   ## dummy example 
    }
    
    0 讨论(0)
提交回复
热议问题