Skip to content

Document how to avoid build-time dependency #76

Open
@krlmlr

Description

@krlmlr

Following @gaborcsardi's advice in https://stat.ethz.ch/pipermail/r-devel/2017-January/073647.html, I tried memoising in .onLoad(), and it worked for me:

# file.R
fun <- function() {
  some_expensive_process()
}

# zzz.R
.onLoad <- function(pkgname, libname) {
  fun <<- memoise::memoise(fun)
}

This eliminates the build-time dependency on memoise and also gets rid of R CMD check warnings about using memoise without importing it.

I wonder if and where we should document this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions