Using R and Declarative Widgets in Jupyter Notebooks
In previous blogs posts such as: Declarative Widget System for Jupyter Notebooks and Adding Declarative Widgets to the Jupyter Notebook we introduced what declarative widgets are, technologies involved, and walked through a use case driven by a survey on user experience conducted by the Jupyter community.
The end result of our work is that practitioners in the R community are no longer limited to a static analytics environments, but can now benefit from increased interactivity and powerful features like built in querying logic to truly explore their data. We know this is a bold statement to make, so lets now show you what we have.
First off you might be asking:
- Where can I checkout the project?
- View example notebooks?
- Our full set of example notebooks covering our supported environments (R, Scala, Python) can be found here.
- This blog will concentrate on our R solutions and you will certainly want to checkout out our base R declarative widgets example to get a handle around features such as functions, channels, dataframes, and even spark dataframes. We are throwing a lot at you, so when you walk through this example notebook make sure to have our documentation handy, which you can get on our Wiki.
- Lastly, get our R querying notebook that covers one of our newest additions querying dataframes and spark dataframes, where querying can be a combination of operations such as: group by, sorting, and filtering on data.
- Get instructions on setting up a development environment?
- Environment setup and build instruction can be found in great detail on our README. Don’t worry though, as our environment is dockerized. The gist of the setup is really git clone, make init dev.
Querying dataframes in R with declarative widgets
Read in data as you normally would in R and create a query UI directly in the notebook:
Sort and filter your data to understand how vendor id’s and fare amounts may be related:
Drill in further by grouping by a specific vendor_id and examining statistics like the vendor’s mean fare amount and tolls amount:
Lastly, tables are nice but you also want to show off some nice graphics while your at it:
These example are using base R data frames, but everything you saw above can be easily reproduced using Spark R data frames. We have the notebook consisting of the taxi data demo along with it’s corresponding Spark implementation available in our notebook examples repository.
Jupyter notebooks provide a great environment to create reproducible and verifiable research reports. We want to push the limits and make this into an analytics environment driven by interactive widgets. The Jupyter community as a whole has done a great job of supporting the python user, but with our recent efforts under the Jupyter Incubator Declarative Widgets Project we have exposed many cutting edge capabilities for the R user and look forward to what they have to say! We are always looking for feedback and collaborators to work with us, so please reach out.