Skip to content

How to use names from a different package inside a module? #281

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

You must be logged in to vote

With ‘box’, the contents of different modules are strictly isolated from each other.

So if you have a module test.R that needs the %>% operator or the filter function (or any other function), you need to import those names inside that module. You can’t put the code for the import into a separate file.

In your case, this means that you need to move the relevant box::use() declaration into test.R:

box::use(dplyr[...])

test <- function(dat) {
  dat %>% 
    filter(x == 3)
}

(Note that I also removed the last line of your test function, since you returned the unmodified dat, which was probably not intended.)

And in your other code that uses test.R, you no longer need to import ‘dplyr’ (unles…

Replies: 1 comment 8 replies

Comment options

You must be logged in to vote
8 replies
@lo-zed
Comment options

@mrismailt
Comment options

@lo-zed
Comment options

@klmr
Comment options

@lo-zed
Comment options

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

This discussion was converted from issue #280 on June 13, 2022 09:00.