How could I render a HTML widget (produced by dygraphs in my case) directly in an external browser (Chrome for instance)? I guess I could save the widget, build a HTML page, link the widget to it and use something like browseURL. I am looking for something more seamless and performance oriented. The equivalent of the "Show in new window" button within R Studio viewer would be perfect (but without having to render the graph in R Studio viewer in the first place).
-- EDIT
Thanks for your suggestion Tan. I have tried with Markdown, seemed simpler than Shiny. But it did not work. Any idea why? (I get a strange "!–html_preserve–" flag in output).
require(data.table)
require(knitr)
require(dygraphs)
dt = data.table(
ts = as.POSIXct( c('2010-01-01','2010-01-02','2010-01-03') ),
value=rnorm(3)
)
write( "```{r}\n dygraph(dt) \n```", file = "tmp.Rmd" )
knitr::knit2html('tmp.Rmd')
browseURL('tmp.html')
Thanks to Jonathan from RStudio for his answer here.
require(data.table)
require(rmarkdown)
require(dygraphs)
dt = data.table(
ts = as.POSIXct( c('2010-01-01','2010-01-02','2010-01-03') ),
value=rnorm(3)
)
write( "```{r}\n dygraph(dt) \n```", file = "tmp.Rmd" )
rmarkdown::render("tmp.Rmd")
browseURL("tmp.html")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With