This is my code:
#####################################
library(plotly)
set.seed(100)
d <- diamonds[sample(nrow(diamonds), 1000), ]
x<-plot_ly(d, x = ~carat, y = ~price, color = ~carat,
size = ~carat, text = ~paste("Clarity: ", clarity))
htmlwidgets::saveWidget(x, “x.html”)
######################################
x.html can not be open by browser. Please see attachment for this “broken” html’s content.
I found out that If I do not use Rstudio, it works. I just switch to RGui. In RGui, the plot will pop up with weird url like “file:///C:/Users/Administrator/AppData/Local/Temp/RtmpEjbViP/viewhtml12383ee75cbb/index.html”.