【问题标题】:How do I use a local `golem` package with `future()`?我如何使用带有 `future()` 的本地 `golem` 包?
【发布时间】:2022-09-27 13:06:22
【问题描述】:

TL;博士

当我正在运行的闪亮应用程序不在我的 win 库中时,如何引用/使用本地包函数?

错误:

Warning: Error in : there is no package called \'humblFinance\'

伪代码:

 output$p1 <- renderPlot({

            future::future({
            out   <- myPackage::collect_price(symbol = input$tickerInput,
                                                 range = \"1m\")
            input <- input
                out   <- out %>%
                    ggplot2::ggplot(ggplot2::aes(x = date, y = fclose)) +
                    ggplot2::geom_line(size = 1) +
                    ggplot2::labs(title = glue::glue(\"{input$tickerInput} Price Chart\"), y = \"Closing Price\", x = \"\")
                return(out)
            }) %...>% (
                function(result){ return(result) }
            ) %...!% (
                function(error){ warning(error) }
            )
        })

尝试在future({}) statement 中使用函数mypackage::myfun() 时出现以下错误。我的 shinyApp 使用golembrochure 基础架构创建,所以我不确定在哪里引用这个包?我尝试在语句中安装包,但似乎不起作用。我应该将未来的调用指向项目根目录中的压缩包吗?

  1. loadNamespace() 没用
  2. attatchNamespace() 没用
  3. remotes::install_local() 没用
  • 包裹在哪里?通常你会在调用使用它们的代码之前安装包,而不是在每次更新绘图时尝试安装包的renderPlot 函数中。
  • @GregorThomas 这个包是在shinyApp 的golem 基础设施中创建的,所以它是一个本地包,不是从cran 或github 安装的......我应该直接future 使用tarball 吗?
  • 抱歉,我根本没用过 golem,但乍一看你的 golem 应用程序是一个 R 包。最好的情况是,您将包放在 NAMESPACE 文件中,并将其视为正常依赖项。如果你不能这样做......也许确保安装了软件包当应用程序启动时,如果不是从 tarball 安装它,那么 - 不在 render 函数内,也绝对不在 future 函数内。
  • 是的@GregorThomas,不知道如何在NAMESPACE 本身中添加一个包自己的名称,我需要使用UseDynLib() 来实现这一点吗?应用程序启动时也会安装包
  • 那么,humblFinance 是 golem 包的名称??那么你不应该在包内使用humblFinance::。您的问题使您看起来像是在谈论不同的包裹。 (好吧,因为您的问题根本没有提到golem,所以您似乎没有使用golem 包......)。您当然不希望软件包尝试自行安装......这没有任何意义。但是您需要安装软件包才能运行它。

标签: r shiny future environment r-promises


【解决方案1】:

您是否尝试过这篇文章中的答案:

I get an error when using {future} and {furrr} functions within a Golem Shiny App, what does it come from?

这个解决方案对我不起作用,但似乎对帖子的作者有用

【讨论】:

    猜你喜欢
    • 2022-07-14
    • 1970-01-01
    • 2019-04-21
    • 2021-03-09
    • 2021-05-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-27
    相关资源
    最近更新 更多