db_html_print <- function(x, ..., view = interactive()) {
fileName <- paste(tempfile(), ".html", sep="")
htmlwidgets::saveWidget(x, file = fileName)
randomFileName = paste0(floor(runif(1, 0, 10^12)), ".html")
baseDir <- "/dbfs/FileStore/rwidgets/"
dir.create(baseDir)
internalFile = paste0(baseDir, randomFileName)
externalFile = paste0(databricksURL, randomFileName, "?o=<workspace-id>")
system(paste("cp", fileName, internalFile))
displayHTML(externalFile)
}
R.utils::reassignInPackage("print.htmlwidget", pkgName = "htmlwidgets", value = db_html_print)
HTML Widgets in Azure Databricks R Notebooks
This example notebook shows how you can get R HTML widgets working in Azure Databricks notebooks. The setup has two steps:
pandoc
, a Linux package that is used by HTML widgets to generate HTMLBoth steps can be automated using init scripts so that when your cluster launches it installs
pandoc
and updates RHTMLwidgets
package automatically.This notebook shows three examples using HTMLWidgets: dygraphs, leaflet, and plotly
Last refresh: Never