【发布时间】:2018-07-06 15:20:41
【问题描述】:
当使用 plotly 可视化数据时,我想将小部件编写为 html 文档,而不需要 htmlwidgets::saveWidget 每次都编写依赖项,假设这些已经到位,以节省处理时间。小部件需要自包含以节省磁盘空间。
library(plotly)
t <- Sys.time()
p <- plot_ly(ggplot2::diamonds, y = ~price, color = ~cut, type = "box")
htmlwidgets::saveWidget(as_widget(p), "test.html", selfcontained = F, libdir = NULL)
print(Sys.time() - t)
Time difference of 4.303076 secs 在我的机器上。
这仅在依赖项中产生约 6 mb 的数据(crosstalk-1.0.0、htmlwidgets-1.2、jquery-1.11.3、plotly-binding-4.7.1.9000、plotly-htmlwidgets-css-1.38.3、plotly- main-1.38.3, typedarray-0.1)
htmlwidgets::saveWidget 写入依赖项,尽管这些文件已经存在。可以预防吗?
【问题讨论】:
标签: r htmlwidgets r-plotly