htmlwidgetshtmlwidgets

使用 R 的 htmlwidgets,可以利用 R 的灵活语法和环境生成交互式绘图。With htmlwidgets for R you can generate interactive plots using R’s flexible syntax and environment. Azure Databricks 笔记本支持 htmlwidgets。Azure Databricks notebooks support htmlwidgets.

设置有两个步骤:The setup has two steps:

  1. 安装 pandoc,这是 htmlwidgets 用来生成 HTML 的 Linux 包。Install pandoc, a Linux package used by htmlwidgets to generate HTML.
  2. 更改 htmlwidgets 包中的一个函数,使其在 Azure Databricks 中正常工作。Change one function in the htmlwidgets package to make it work in Azure Databricks.

你可以使用初始化脚本来自动执行第一步,以便群集在启动时安装 pandoc。You can automate the first step using an init script so that the cluster installs pandoc when it launches. 你应在使用 htmlwidgets 包的每个笔记本中执行第二步,即更改 htmlwidgets 函数。You should do the second step, changing an htmlwidgets function, in every notebook that uses the htmlwidgets package.

笔记本演示如何将 htmlwidgets 与 dygraphsleafletplotly 配合使用。The notebook shows how to use htmlwidgets with dygraphs, leaflet, and plotly.

重要

对于每个库调用,都将下载包含呈现的绘图的 HTML 文件。With each library invocation, an HTML file containing the rendered plot is downloaded. 该绘图不以内联方式显示。The plot does not display inline.

htmlwidgets 笔记本htmlwidgets notebook

获取笔记本Get notebook