The example that comes with the package rglwidgetis quite complex; I created a simple example shiny/rglwidgetbelow. The plot looks fine, but every time I switch the checkbox, a new image is added to the browser window.
How can I replace / overwrite the first graph?
options(rgl.useNULL = TRUE)
library(shiny)
library(rglwidget)
library(rgl)
app = shinyApp(
ui = bootstrapPage(
checkboxInput("rescale", "Rescale"),
rglwidgetOutput("rglPlot")
),
server = function(input, output) {
output$rglPlot <- renderRglwidget({
try(rgl.close())
if (input$rescale) aspect3d(1,1,10) else aspect3d(1,1,1)
spheres3d(rnorm(100), rnorm(100), rnorm(100,sd = 0.1), col = "red",
radius = 0.1)
axes3d()
rglwidget()
})
})
runApp(app)
Session Information:
R version 3.2.2 (2015-08-14)
Platform: i386-w64-mingw32/i386 (32-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252
[3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C
[5] LC_TIME=German_Germany.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] rgl_0.95.1429 rglwidget_0.1.1431 shiny_0.12.2
loaded via a namespace (and not attached):
[1] htmlwidgets_0.5.1 R6_2.1.1 rsconnect_0.4.1.9 htmltools_0.2.7
[5] tools_3.2.2 yaml_2.1.13 Rcpp_0.12.2 knitr_1.11
[9] jsonlite_0.9.19 digest_0.6.8 xtable_1.8-0 Cairo_1.5-9
[13] httpuv_1.3.3 mime_0.4
source
share