Automatically save interactive graph in R to the specified location as a .html file

I am using the threejs library in R.

  library(threejs)
  z <- seq(-10, 10, 0.01)
  x <- cos(z)
  y <- sin(z)
scatterplot3js(x,y,z, color=rainbow(length(z)))

I need to save the interactive graph created by the above commands as a .html file in the specified folder without using the drop-down list (in Rstudio) in viwer → export, which "saves as a web page".

Is there any R code for this?

+4
source share
1 answer

Using the package htmlwidgets, you can do ...

library(htmlwidgets)

dir.create("Z:\\new folder")

saveWidget(scatterplot3js(x,y,z, color=rainbow(length(z))), 
           file="Z:\\new folder\\scatterplot.html")
+4
source

Source: https://habr.com/ru/post/1612228/


All Articles