You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use custom functions stored in the utils_helper.R file in a golem Shiny App with packages like future/furrr/rmarkdown but the custom functions can't be found.
When using custom function with future/furrr packages, the error message is: Error: there is no package called 'packageName'
where packageName is the name of the golem Shiny App.
An example of this is below:
app_ui
#' The application User-Interface
#'
#' @param request Internal parameter for `{shiny}`.
#' DO NOT REMOVE.
#' @import shiny
#' @noRd
app_ui <- function(request) {
tagList(
# Leave this function for adding external resources
golem_add_external_resources(),
# Your application UI logic
fluidPage(
plotOutput("plot")
)
)
}
#' Add external Resources to the Application
#'
#' This function is internally used to add external
#' resources inside the Shiny application.
#'
#' @import shiny
#' @importFrom golem add_resource_path activate_js favicon bundle_resources
#' @noRd
golem_add_external_resources <- function() {
add_resource_path(
"www",
app_sys("app/www")
)
tags$head(
favicon(),
bundle_resources(
path = app_sys("app/www"),
app_title = "renderRmd.shinyapps.io"
)
# Add here other external resources
# for example, you can add shinyalert::useShinyalert()
)
}
app_server.R
#' The application server-side
#'
#' @param input,output,session Internal parameters for {shiny}.
#' DO NOT REMOVE.
#' @import shiny progressr future furrr
#' @noRd
app_server <- function(input, output, session) {
output$plot <- renderPlot({
X <- 1:24
plan(multisession(workers = 6))
future({
msgFunc()
})
withProgressShiny(message = "Calculation in progress",
detail = "This may take a while ...", value = 0, {
p <- progressor(along = X)
y <- future_map(X, function(x) {
Sys.sleep(1)
msgFunc(x) #If comment out this line, the app works
p()
})
})
plot(cars)
})
}
utils_helper.R
#' helpers
#'
#' @description A utils function
#'
#' @return The return value, if any, from executing the utility.
#'
#' @noRd
msgFunc <- function(x){
print(
paste(
"Calculating",
x
)
)
}
@ColinFay provided a solution (used above) but this isn't working for me
I also tried using a similar solution when rendering an Rmd file that used custom functions, but this also didn't work
Thanks for the assistance
The text was updated successfully, but these errors were encountered:
I'm trying to use custom functions stored in the utils_helper.R file in a golem Shiny App with packages like future/furrr/rmarkdown but the custom functions can't be found.
When using custom function with future/furrr packages, the error message is:
Error: there is no package called 'packageName'
where packageName is the name of the golem Shiny App.
An example of this is below:
app_ui
app_server.R
utils_helper.R
@ColinFay provided a solution (used above) but this isn't working for me
I also tried using a similar solution when rendering an Rmd file that used custom functions, but this also didn't work
Thanks for the assistance
The text was updated successfully, but these errors were encountered: