【发布时间】: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 使用golem 和brochure 基础架构创建,所以我不确定在哪里引用这个包?我尝试在语句中安装包,但似乎不起作用。我应该将未来的调用指向项目根目录中的压缩包吗?
-
loadNamespace()没用 -
attatchNamespace()没用 -
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