Using R and Declarative Widgets in Jupyter Notebooks

Share: Share on FacebookTweet about this on TwitterShare on Google+Share on LinkedInShare on RedditEmail this to someonePrint this page

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?
    • We are working with the continually growing Jupyter community and our project is declarative widgets, a Jupyter incubator project hosted on GitHub.
  • 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:

R taxi fares and display

Sort and filter your data to understand how vendor id’s and fare amounts may be related:

vendor_id and fare_amounts

Drill in further by grouping by a specific vendor_id and examining statistics like the vendor’s mean fare amount and tolls amount:

group_by and vendor_id

Lastly, tables are nice but you also want to show off some nice graphics while your at it:

group by graphic

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.

Conclusion

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.

Share: Share on FacebookTweet about this on TwitterShare on Google+Share on LinkedInShare on RedditEmail this to someonePrint this page
Michael Poplavski
Michael is a Software Engineer in IBM Emerging Technologies.
Michael Poplavski

Latest posts by Michael Poplavski (see all)

Michael Poplavski

Leave a Reply

Your email address will not be published. Required fields are marked *