Skip to content

Instantly share code, notes, and snippets.

@saptarshiguha
Created November 18, 2015 22:26
Show Gist options
  • Save saptarshiguha/111c051166d2eb417bad to your computer and use it in GitHub Desktop.
Save saptarshiguha/111c051166d2eb417bad to your computer and use it in GitHub Desktop.
## In https://github.com/rstudio/htmltools/blob/master/R/html_print.R#L41
## html_print doesn't have an option on how and where to write the html
## it always creates anothe temporary directory and writes the HTML there
## This bypasses that with an uglry recursive copy ...
options(rbokehViewDir = tempfile("rbokehviz"))
if(!file.exists(getOption("rbokehViewDir")))
dir.create(getOption("rbokehViewDir"))
## On my remote system, i have a public_html/tmp folder setup that i
## view from chrome (which can also view PDF inside the browser
## window) in this case:
## options(rbokehViewDir = "~/public_html/tmp/rbokeh")
options(viewer = (function(){
first <- TRUE
function(u,height){
rbokehdir <- getOption("rbokehViewDir")
for(k in list.files(dirname(u),full=TRUE)){
file.copy(k, rbokehdir, overwrite=TRUE,recursive=TRUE)
}
index_html <- file.path(rbokehdir, "index.html")
message(sprintf("Viewing figure at %s", index_html))
if(first){
utils::browseURL(index_html)
first <<- FALSE
}
}
})())
library(rbokeh)
p <- figure(logo='None',tool=NULL)
p <- ly_points(p,Sepal.Length, Sepal.Width, data = iris,
color = Species, glyph = Species,
hover = list(Sepal.Length, Sepal.Width))
p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment