webRMicroIDE: an enhancement to using webR

Dear Codea Community,

I built webRMicroIDE as to help me more efficiently use Steppers’ great webR-lua bridge project. It provides an expanded REPL capability which allows users somewhat more space to input both lua and R commands (including graphical commands and plots) and display their results in real-time. Like webR, it can install many of R’s packages. In addition, since many R packages now produce html output, the project provides some convenience features to store html in a lua variable, save that variable as a file named WebR.html in Codea documents folder, and retrieve and open and display that .html file with Codea’s in-app browser capability.

My main use case is to provide a real-time environment to test out combinations of graphical and non-graphical lua code mixed with R. As I better learn how to create gui controls in Codea, I’ll then make some further projects demonstrating the benefit from using Codea lua as a front-end to analyzing and displaying results from R.

I submitted the project today for addition to the WebRepo.

Special thanks to my online programmer colleague, Kartik, for helping with advanced troubleshooting, and for Steppers for bringing the webR-lua bridge to bear. I hope others find it useful and welcome further suggestions on the project.

(Note: webRMicroIDE currently requires an internet connection to download initial webR wasm code when starting)

Additional tips that didn’t make it into this initial release:

The latest plot is stored in luavar ‘plot’ as a .png; you can thus saveImage(asset.documents…‘Plot.png’,plot)

webR’s file system cannot yet write directly to Codea documents; access the root of R file system by R.FS [‘/’]

R file system commands: R(‘getwd()’), R(‘setwd()’), R(‘list.files()’); subdirectories: R.FS.home, etc

Transfer file from documents to R: luavar = readText(asset.documents.spreadsheet); R.FS[‘Spreadsheet.csv’]=luavar

Here is an approximate 5 minute visual introduction and tutorial to webRMicroIDE:

1 Like