I am currently working on a Golem Shiny App called "package_name" (which is a requirement for me) for which some functions I created need to use functions from the {furrr}
and {future}
packages.
However, whenever I try to run them, I get the following error :
Error : there is no package called 'package_name'
Please note that whenever any function that does not use either package works perfectly fine.
Does anyone know what the problem might be ?
Thanks !
While building the application with {golem}
, the package with the app is not installed on your machine.
When you use {future}
, the code is run inside another R session, meaning that the objects are transported and the libraries reloaded.
BUT if you try to use a function from inside your current app into your future, you need to make it "transportable", and using package_name::function()
will not work because your package is not installed.
Let's say you need to use current_app_fun()
, defined inside your package.
Technically, {future}
will be able to transport this function, as it uses {globals}
to identify the objects to transport to the new R session.
observeEvent( input$bla , {
# future() will identify that it needs to
# transport current_app_fun()
future({
current_app_fun()
})
})
You can also do an extra step just to be extra cautious:
observeEvent( input$bla , {
func_for_future <- current_app_fun
future({
func_for_future()
})
})
Cheers, Colin