ipywidgets
ipywidgets copied to clipboard
Running in Reticulate in IRKernel
Problem
I want to have an R jupyter notebook, using ggploty for interactive plots, and also to have widgets to control certain parts of the code.
Looking at #792 which is 6 years old, there's no good solution:
- Yes,
ggplotlygives us interactive plots. However interactive plots != widgets. - The
declerativewidgetspackage has been "retired" 5 years ago.
Proposed Solution
-
Run
ipywidgetsinsidereticulateinside IRKernel - this works, at least it doesn't crash. -
Somehow pass the widget HTML to IRKernel to be displayed - I couldn't figure out this part but it "should" be possible?
-
Then access the user-modified widget state from R code, probably via
reticulateto access the Python accessible widget state - I'm wildly guessing here but this "should" also be possible?
Additional context
A possibity which does work is to use rpy2, that is:
- Run a Python jupyter notebook
- Run
ipywidgets, collect the widget state - Use
rpy2to invoke the R code, wrapped insiderobjects.r.
The problem is that we end up with a Python notebook where every cell looks like robjects.r(''' ... lots of R code '''), giving up on all the R-specific features (syntax highlighting, autocompletion, etc.).