运行此代码时出现错误:
library(dash)
app <- Dash$new()
app$layout(
htmlDiv(
list(
dccGraph("graph"),
dccSlider(
id = "slider",
min = 500, max = 700, step = 50, value = 600,
marks = list(500, 600, 700)
)
)
)
)
错误:
Error in htmlDiv(list(dccGraph("graph"), dccSlider(id = "slider", min = 500, :
could not find function "htmlDiv"
现在我看到 htmlDiv 是 dashCoreComponents 的一部分,但根据 https://github.com/plotly/dash-core-components “从 Dash 2 开始,dash-core-components 的开发已转移到主 Dash 存储库。此软件包的存在是为了向后兼容”
所以我不需要加载
library(dashCoreComponents)
,对吗?但即使我尝试,我也做不到,因为如果我理解正确的话,它是library(dash)
的一部分。所以不会是因为这个吧?
有趣的问题,由于去年从 CRAN 中删除了
dash
,这一事实加剧了这一问题,并且可能因已删除的 dashR
软件包的存在而进一步感到困惑。从这个角度来看,您的代码似乎是合法的。但是,查看 https://github.com/cran/dash/blob/18e9bfa25389cc7027d1a54fcd7716aed8a99b41/R/dashHtmlComponents.R#L730 及其 NAMESPACE
,它已定义但未导出。这看起来像是一个错误报告,尽管不难看出 Dash for R 的概念受到鼓励但没有得到很好的支持。
可以通过
app
调用它来使 :::
工作。
library(dash)
app <- Dash$new()
app$layout(
dash:::htmlDiv(
list(
dccGraph("graph"),
dccSlider(
id = "slider",
min = 500, max = 700, step = 50, value = 600,
marks = list(500, 600, 700)
)
)
)
)
# Warning in fn_summary$obj : partial match of 'obj' to 'objs'
# Warning in fn_summary$obj : partial match of 'obj' to 'objs'
# Warning in fn_summary$obj : partial match of 'obj' to 'objs'
# Warning in fn_summary$obj : partial match of 'obj' to 'objs'
# Warning in fn_summary$obj : partial match of 'obj' to 'objs'
# Warning in fn_summary$obj : partial match of 'obj' to 'objs'
# Warning in fn_summary$obj : partial match of 'obj' to 'objs'
# Warning in fn_summary$obj : partial match of 'obj' to 'objs'
app
(这不是一个可持续的解决方案,但是,最好修复包本身。)