Interactive 3D in Shiny (shinyRGL)

The rgl package has been used to produce rich, interactive 3D graphics within R using the OpenGL framework for some time. The rgl authors also added the ability to export to WebGL, allowing R authors to produce interactive 3D graphics that were accessible from within any modern web browser.

This functionality can now be leveraged within the Shiny framework using the new shinyRGL package — allowing users of R who may have no prior web development experience to create interactive web applications which incorporate 3D graphics. Examples such as this 3D cube filled with variable numbers of points or this modification of the ‘bivar’ example included in rgl can be produced with minimal effort. (The source code for both of these applications is available in the /examples/ directory of the shinyRGL package; both are under 100 lines of code and are written entirely in R.)

The package was just released on CRAN and should now be available from your preferred CRAN mirror. You can install using the command:

install.packages("shinyRGL")

Alternatively, you can download the bleeding-edge version of the code, view more details about the implementation, or track the development of the package on our GitHub repository. Please use GitHub to notify us of any issues or feature requests you may come across, as well.

Below is a sample of the kinds of graphics that can be produced using shinyRGL by writing only R code. Be sure to pan the scene by clicking and dragging, zoom using the scroll wheel, and even change the point of view by clicking and dragging with the right mouse button.

You must enable Javascript to view this page properly.

5 Comments

  1. maskonur says:

    > install.packages(“shinyRGL”)
    Warning in install.packages :
    package ‘shinyRGL’ is not available (for R version 3.0.2)

    • Jeff Allen says:

      It may take a day to trickle down to the CRAN mirror you’re using (it just got approved over the weekend). Can you try it again later today?

      Also, what Operating System are you using?

  2. Michael Kane says:

    Great package! I’ve submitted a pull request on GitHub to make the examples easier to run.

  3. Dan McCloskey says:

    Thanks for sharing this! I followed your initial post earlier this year and got rgl up and running on a headless server. Getting the second graph up was all the more easier with this integration. I’m looking to have the data points in my 3dplot show a pop-up window with a clickable link when you hover over them with a mouse. Any idea whether this would be possible with rgl plots?

    • Jeff Allen says:

      Glad it’s working for you! Unfortunately, ShinyRGL doesn’t really have the ability to extend beyond what RGL can render. Since RGL doesn’t offer the ability to handle mouse events, ShinyRGL can’t either. Certainly seems like a reasonable feature request for RGL, though! I’d love to see this added to the package.

Trackbacks/Pingbacks

  1. I did a map! | Katatrepsis - [...] of the data, and there are many neater ways to do this.  In particular, R gives the option to ...

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">