posit-dev / r-shinylive

https://posit-dev.github.io/r-shinylive/
Other
177 stars 18 forks source link

Workaround to load/retrieve high dimentional data files to be used by app #69

Open rekren opened 8 months ago

rekren commented 8 months ago

Hi there,

Many thanks to come up with shiny implementation for static html pages! I have an issue to find a workaround for webr, to work with data formats other than csv file.

Converting a high dimentional data into csv is super inefficient and, I am intrigued that what other approaches may work considering the architecture of WebR?

I have read about local folder support (https://github.com/posit-dev/r-shinylive/issues/13), and RDS loading problem (https://github.com/posit-dev/r-shinylive/issues/65).

Is there a way to make an app run with a data in e.g. HDF5 file format ?

Thank you for your time and efforts !

seanbirchall commented 6 months ago

@rekren hosting the data remotely could work. Assuming you're currently trying to compile this data statically with your app that won't work. I have noticed that csv's do work but internally you can actually inspect what's happening and the app will create a comma separated string within app.json (unlikely many additional files will be supported doing this, nor should they). Remotely storing the file on any blob storage that can be accessed via http should do, you can then fetch the file using download.file. Somewhat similar to mounting a folder which will probably also work already and be the recommended way of doing this (https://docs.r-wasm.org/webr/latest/mounting.html).

georgestagg commented 6 months ago

The data loading problem in #65 should now be fixed. As Sean mentions, the {shinylive} R package should now be able to export() binary data files, including RDS and other formats.

Here is an example of a Shinylive app (in this case with binary data distributed via GitHub gist) that loads various types of data files into memory:

https://shinylive.io/r/editor/#gist=0af60c8b3a63f1c9e253838fdb8957a7

[Source]


I'm unaware of a way to load HDF5 files into webR right now, but eventually I expect we'll include the netcdf and hdf5 open-source engines as part of webR's WebAssembly libraries. Once that work has been done, the R packages for reading hdf5 files should be loadable in webR and Shinylive.