Description Usage Arguments Details See Also Examples
Create an HTML widget to sync R data with an A-Frame scene via the data-binding A-Frame component.
1 | aDataScene(data, elementId = NULL)
|
data |
A data frame or a list of vectors, matrices, and/or data frames |
elementId |
Optionally define the output HTML element |
Data will be synced to the data-binding
system from the
gg-aframe JavaScript
library for A-Frame. Data can be bound to automatically update components
in the scene with the data-binding
A-Frame component. Repeat
calls (e.g. within a Shiny reactive expression) will update the
data-binding
store and refresh bound components with the new data.
If data
is a data frame, each variable will be available, by name,
as a JavaScript Array in the scene data store (i.e. long form).
If it is a list, each list item will be available, by name, as a
JavaScript Array in the scene data store. Data frames within the list
will be available as an array of Objects, with each object
representing a row from the data frame (i.e. wide form).
To send multiple data frames in long form, combine them with
c
, and each column will be available by name
in the A-Frame data-binding
system. To send multiple
data frames in wide form, combine them as named items in
a list
, and each data frame will be available as an array of
objects (rows) under the name used.
Note: aDataScene
is only compatible for use in Shiny
apps viewed with a modern Web browser and internet connection.
WebVR data visualizations are not available in Rmd documents, R Notebooks,
or the RStudio Viewer at this time.
1 2 3 4 5 6 7 8 9 | library(dplyr)
library(scales)
# Execute within a renderADataScene call in a Shiny server
iris %>%
# scale positional data to (0,1)
mutate_if(is.numeric, rescale) %>%
# make data available in JavaScript
aDataScene()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.