Skip to content

Migrating old package structure to box module #342

Answered by klmr
mpettis asked this question in Q&A
Discussion options

You must be logged in to vote

If I understand you correctly, you want to “pool” all the functions defined in the files under mymod inside a single module, correct?

There’s a Stack Overflow question asking something quite similar.

The solution is to add a __init__.R file under mymod which imports and exports the submodules:

# mymod/__init__.R:

#' @export
box::use(
  ./fun1[...],
  ./fun2[...],
)

Afterwards, importing mymod will make all exported objects from the nested modules (= the source files) available.

Now you can use it in R/tryBox.R, for example:

box::use(../mymod)

mymod$fun1()

Note the relative import (../mymod).

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@mpettis
Comment options

@mpettis
Comment options

@klmr
Comment options

@mpettis
Comment options

Answer selected by mpettis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants