<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>Jupyter Blog - Romain François</title><link href="https://jasongrout.github.io/medium-archive/pelican/" rel="alternate"/><link href="https://jasongrout.github.io/medium-archive/pelican/feeds/author-romain-francois.atom.xml" rel="self"/><id>https://jasongrout.github.io/medium-archive/pelican/</id><updated>2024-01-22T17:20:00+00:00</updated><subtitle>The Project Jupyter blog: news, releases, and community stories, archived from blog.jupyter.org.</subtitle><entry><title>Meet Xeus-R: a future-proof Jupyter kernel for R</title><link href="https://jasongrout.github.io/medium-archive/pelican/posts/2024/meet-xeus-r-a-future-proof-jupyter-kernel-for-r/" rel="alternate"/><published>2024-01-22T17:20:00+00:00</published><updated>2024-01-22T17:20:00+00:00</updated><author><name>Romain François</name></author><id>tag:jasongrout.github.io,2024-01-22:/medium-archive/pelican/posts/2024/meet-xeus-r-a-future-proof-jupyter-kernel-for-r/</id><summary type="html">&lt;p&gt;The Jupyter ecosystem provides a versatile and user-friendly platform for data analysis and scientific computing, it has democratised…&lt;/p&gt;
</summary><content type="html">&lt;figure&gt;
&lt;img alt="Screenshot of a Jupyter notebook with two cells displayed alongside a contextual help panel. The first cell shows the execution of an R command display(head(mtcars, 3)). The output is a nicely formatted table display with 3 rows. The second cell contains is a call to the ggplot function from the ggplot2 package. The output is a scatter plot of the variables hwy and displ, coloured by the class factor. The cursor shows auto completion for ggplot. On the right, contextual help for ggplot." src="https://jasongrout.github.io/medium-archive/pelican/posts/2024/meet-xeus-r-a-future-proof-jupyter-kernel-for-r/images/001-1_cFmKZKFycjvG1v_Xub4snQ.webp" loading="lazy" data-body-image=""&gt;
&lt;figcaption&gt;JupyterLab session with a notebook powered by the Xeus-R kernel for R&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;The &lt;em&gt;Jupyter&lt;/em&gt; ecosystem provides a versatile and user-friendly platform for data analysis and scientific computing, it has democratised access to powerful tools for researchers, scientists, educators, and data professionals.&lt;/p&gt;
&lt;p&gt;The name &lt;em&gt;Jupyter&lt;/em&gt;, a blend of &lt;em&gt;Julia&lt;/em&gt;, &lt;em&gt;Python&lt;/em&gt;, and &lt;em&gt;R&lt;/em&gt; has always hinted at its relevance in multiple scientific programming languages and has since conquered new horizons thanks to its flexible and extensible design.&lt;/p&gt;
&lt;p&gt;Underneath the interactive surface of &lt;em&gt;Jupyter&lt;/em&gt; lie the &lt;em&gt;Jupyter&lt;/em&gt; kernels, a set of language specific engines orchestrating the dynamic execution and exploration of code. Kernels implement the &lt;em&gt;Jupyter&lt;/em&gt; protocol, a shared specification of the communication process between notebooks and kernels, defining how messages, commands and outputs are exchanged and processed.&lt;/p&gt;
&lt;p&gt;The &lt;em&gt;Xeus&lt;/em&gt; framework is a central piece of the puzzle, offering a reference to facilitate &lt;em&gt;Jupyter&lt;/em&gt; kernel implementations. The speed, extensibility, and alignment with the official protocol make &lt;em&gt;Xeus&lt;/em&gt; a perfect technology to implement new kernels.&lt;/p&gt;
&lt;h2 id="xeus-r"&gt;Xeus-R&lt;/h2&gt;
&lt;p&gt;Today, we, &lt;em&gt;a collaborative team led by Romain François and supported by QuantStack&lt;/em&gt;, are thrilled to announce the initial release of &lt;em&gt;Xeus-R&lt;/em&gt;, a future-proof &lt;em&gt;Jupyter&lt;/em&gt; kernel for R. &lt;em&gt;Xeus-R&lt;/em&gt; builds upon the components of &lt;em&gt;Xeus&lt;/em&gt; to facilitate the use of &lt;em&gt;R&lt;/em&gt; in &lt;em&gt;Jupyter&lt;/em&gt; notebooks and already supports typical capabilities: &lt;em&gt;R&lt;/em&gt; code execution, inspection, completion, and contextual help.&lt;/p&gt;
&lt;p&gt;The recent advancements in support for &lt;em&gt;WebAssembly&lt;/em&gt; in the &lt;em&gt;R&lt;/em&gt; world led by the &lt;em&gt;WebR&lt;/em&gt; project, the flexible design of Xeus, and the rise of &lt;em&gt;JupyterLite&lt;/em&gt; all contribute to our strong belief that &lt;em&gt;Xeus-R&lt;/em&gt; has the potential to deliver &lt;em&gt;Jupyter&lt;/em&gt; in-browser experience for data scientists using &lt;em&gt;R&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Xeus-R&lt;/em&gt; is currently at the stage of a proof of concept, but we wanted to communicate about it early to broadcast our excitement about its potential, share some of our thoughts, and initiate a conversation.&lt;/p&gt;
&lt;h2 id="relationship-with-irkernel"&gt;Relationship with IRkernel&lt;/h2&gt;
&lt;p&gt;While the &lt;em&gt;IRkernel&lt;/em&gt; project paved the way and is the current reference implementation of a &lt;em&gt;Jupyter&lt;/em&gt; kernel for R, it does not take advantage of the &lt;em&gt;Xeus&lt;/em&gt; infrastructure and includes a complete implementation of the &lt;em&gt;Jupyter&lt;/em&gt; protocol, down to the composition of all of the &lt;em&gt;JSON&lt;/em&gt; messages and most importantly how they are transported through &lt;em&gt;ZeroMQ&lt;/em&gt; sockets.&lt;/p&gt;
&lt;p&gt;In contrast, &lt;em&gt;Xeus-R&lt;/em&gt; fully embraces and leverages the capabilities of &lt;em&gt;Xeus&lt;/em&gt;, while borrowing some higher level concepts from &lt;em&gt;IRkernel&lt;/em&gt; and reusing features from its dependent packages &lt;em&gt;IRdisplay&lt;/em&gt; and &lt;em&gt;repr&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;We believe this path will benefit future development as it gives us the freedom to work on innovations that are specific to the needs of &lt;em&gt;R&lt;/em&gt; users, and let &lt;em&gt;Xeus&lt;/em&gt; absorb evolutions of the &lt;em&gt;Jupyter&lt;/em&gt; protocol.&lt;/p&gt;
&lt;h2 id="key-features"&gt;Key features&lt;/h2&gt;
&lt;p&gt;&lt;em&gt;Xeus-R&lt;/em&gt; implements the basic building blocks of what you would expect from a &lt;em&gt;Jupyter&lt;/em&gt; kernel. The results of a code cell, i.e. the value of its last expression are displayed in the output, taking advantage of &lt;em&gt;ANSI&lt;/em&gt; escape codes for colours as were made popular by the &lt;em&gt;crayon&lt;/em&gt; and later &lt;em&gt;cli&lt;/em&gt; &lt;em&gt;R&lt;/em&gt; packages.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://jasongrout.github.io/medium-archive/pelican/posts/2024/meet-xeus-r-a-future-proof-jupyter-kernel-for-r/images/002-1_XznRckf13HpNy_S7h7-_iA.webp" alt="Screenshot of a Jupyter notebook with 3 cells visible. The first cell [2] contains a line of R code that uses cat and glue to print “hello world” with “world” coloured in green thanks the col_green function from the cli package. The second cell [3] shows the command head(mtcars) which outputs a plain text version of the first 6 rows of the mtcars data frame. The third cell [9] contains R code that loads the tibble package and then prints mtcars as a tibble, therefore benefitting from formatting." loading="lazy" data-body-image=""&gt;&lt;/p&gt;
&lt;p&gt;Traditional and &lt;em&gt;ggplot2&lt;/em&gt;-powered graphics are captured and displayed as images. The aspect ratio of plots can be controlled by setting the &lt;em&gt;repr.plot.height&lt;/em&gt; and &lt;em&gt;repr.plot.width&lt;/em&gt; options either globally, or locally via the &lt;em&gt;cell_options()&lt;/em&gt; function.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://jasongrout.github.io/medium-archive/pelican/posts/2024/meet-xeus-r-a-future-proof-jupyter-kernel-for-r/images/003-1_oi1bSbjYZg_I_H104v-75g.webp" alt="A Jupyter notebook cell [13] with R code and its output. The code sets options locally with the cell_options() function and then creates a box plot with the following code: boxplot(decrease ~ treatment, data = OrchardSprays, col = “bisque”, log = “y”). The output is a a graphic with 8 boxplots, representing the treatment factor and its levels A to H on the x axis, and the variable decrease on the y axis, with a logarithmic scale." loading="lazy" data-body-image=""&gt;&lt;br&gt;
&lt;img src="https://jasongrout.github.io/medium-archive/pelican/posts/2024/meet-xeus-r-a-future-proof-jupyter-kernel-for-r/images/004-1_7bZITs9PxXYWwqgDWEniJg.webp" alt="Screenshot of a Jupyter notebook cell [15] with R code and output. The code is loading the ggplot2 package and then creating a scatterplot with the following code: ggplot(mpg, aes(displ, hwy, colour = class)) + geom_point(). The resulting plot is a scatter plot with displ on the x axis and fwy on the y axis, showing different colored points representing different classes of vehicles from the class factor." loading="lazy" data-body-image=""&gt;&lt;/p&gt;
&lt;p&gt;Thanks to the scaffolding in place in the &lt;em&gt;IRdisplay&lt;/em&gt; and &lt;em&gt;repr&lt;/em&gt; packages, &lt;em&gt;Xeus-R&lt;/em&gt; is also able to emit richer displays through mime bundles.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://jasongrout.github.io/medium-archive/pelican/posts/2024/meet-xeus-r-a-future-proof-jupyter-kernel-for-r/images/005-1_-T33jRshu16eWh96_OVuvA.webp" alt="Screenshot of a Jupyter notebook with 2 cells with R code. The first cell [16] contains the command display(1:10). The output shows a rich representation of 1:10: the numbers 1 to 10 separated by dots. The second cell [17] also uses the display function to create a rich display of the first 6 rows of the mtcars data frame: display(head(mtcars)). The result presents the data frame as a well formatted table display with alternating shading for rows to improve readability." loading="lazy" data-body-image=""&gt;&lt;/p&gt;
&lt;p&gt;In contrast with &lt;em&gt;IRkernel&lt;/em&gt;, the rich displays need to be explicitly requested with the &lt;em&gt;display()&lt;/em&gt; function. There are cases however, such as &lt;em&gt;HTML&lt;/em&gt; widgets, where automatic rich display makes the most sense because a text/plain representation is not valuable.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://jasongrout.github.io/medium-archive/pelican/posts/2024/meet-xeus-r-a-future-proof-jupyter-kernel-for-r/images/006-1_5QOitnpbBdDNpQ9ERIILpg.webp" alt="Screenshot of a Jupyter notebook cell [24] showing R code that uses packages htmltools and plotly to create an HTML widget with 2 plotly-powered histograms. The result first shows information messages about conflicts, then shows two typical plotly-powered histograms. The top histogram shows a selection, indicating that the display is about to be zoomed in a smaller value range, to show that the HTML widget can be interacted with." loading="lazy" data-body-image=""&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Xeus-R&lt;/em&gt; also supports contextual help and includes a basic completion system, based on the internal &lt;em&gt;utils::.getTokenFromLine()&lt;/em&gt; system.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://jasongrout.github.io/medium-archive/pelican/posts/2024/meet-xeus-r-a-future-proof-jupyter-kernel-for-r/images/007-1_jWuiihVGV0_7utFx3Tzvng.webp" alt="Screenshot of a Jupyter notebook interface with an open R code cell and a contextual help panel side by side. On the left side, the code cell is active with the incomplete R function call “rnorm(“ being typed, and an auto-completion tooltip showing the options “n=”, “mean=”, “sd=”. The tooltip also shows a repetition of the function name “rnorm”. On the right side, the contextual help panel shows the documentation for the rnorm function." loading="lazy" data-body-image=""&gt;&lt;/p&gt;
&lt;h2 id="installation-and-getting-started"&gt;Installation and Getting Started&lt;/h2&gt;
&lt;p&gt;At the time of writing this article, &lt;em&gt;Xeus-R&lt;/em&gt; is only available and tested to work on Unix-based systems. We consciously decided to focus initial efforts on features rather than platform comprehensiveness, but we should be able to fix this soon enough.&lt;/p&gt;
&lt;p&gt;The easiest way to get up and running with &lt;em&gt;Xeus-R&lt;/em&gt; is to install it from conda-forge:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;mamba&lt;span class="w"&gt; &lt;/span&gt;install&lt;span class="w"&gt; &lt;/span&gt;xeus-r
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Instructions to build from source are available in the github repository for &lt;em&gt;Xeus-R&lt;/em&gt;: &lt;a href="https://github.com/jupyter-xeus/xeus-r"&gt;https://github.com/jupyter-xeus/xeus-r&lt;/a&gt;&lt;/p&gt;
&lt;h2 id="looking-ahead-jupyterlite-integration"&gt;Looking ahead: JupyterLite Integration&lt;/h2&gt;
&lt;p&gt;Another benefit of a &lt;em&gt;Xeus&lt;/em&gt;-based approach is that it has been designed in a way that supports in-browser experience to power &lt;em&gt;JupyterLite&lt;/em&gt;. Together with the recent developments around &lt;em&gt;WebR&lt;/em&gt;, we can envision &lt;em&gt;R&lt;/em&gt; becoming a first-class citizen in the &lt;em&gt;JupyterLite&lt;/em&gt; world.&lt;/p&gt;
&lt;p&gt;This is an exciting vision and will serve as our North Star ⭐️ for future developments of &lt;em&gt;Xeus-R&lt;/em&gt;.&lt;/p&gt;
&lt;h2 id="conclusion"&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Join us in welcoming &lt;em&gt;Xeus-R&lt;/em&gt;, a &lt;em&gt;Jupyter&lt;/em&gt; kernel for &lt;em&gt;R&lt;/em&gt; that leverages the robust foundation of &lt;em&gt;Xeus&lt;/em&gt; architecture. &lt;em&gt;R&lt;/em&gt; is a language of paramount importance for Data Science and Scientific Computing and it rightfully deserves its place as a first-class citizen within the &lt;em&gt;Jupyter&lt;/em&gt; ecosystem.&lt;/p&gt;
&lt;p&gt;We firmly believe that &lt;em&gt;Xeus-R&lt;/em&gt; has the potential to become a reference implementation for an &lt;em&gt;R&lt;/em&gt; kernel, well positioned to tackle the challenges of the ever-evolving landscape of in-browser Scientific Computing, a promising future led by the &lt;em&gt;JupyterLite&lt;/em&gt; and &lt;em&gt;WebR&lt;/em&gt; projects.&lt;/p&gt;
&lt;h2 id="acknowledgements"&gt;Acknowledgements&lt;/h2&gt;
&lt;p&gt;The work by Romain François on Xeus-R was funded by &lt;a href="https://twitter.com/QuantStack"&gt;QuantStack&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="author-bio"&gt;Author Bio&lt;/h2&gt;
&lt;p&gt;&lt;a href="http://www.linkedin.com/in/romain-francois"&gt;Romain François&lt;/a&gt; is a prominent figure in the &lt;em&gt;R&lt;/em&gt; community, recognised for his longstanding contributions to &lt;em&gt;R&lt;/em&gt; programming and Data Analysis. With a profound passion for open-source software and commitment to advancing the capabilities of &lt;em&gt;R&lt;/em&gt;, he has earned a well-deserved reputation as a respected expert.&lt;/p&gt;
&lt;p&gt;Romain’s expertise encompasses a wide spectrum of &lt;em&gt;R&lt;/em&gt;-related fields, including package development, data manipulation, and interoperability with other programming languages. He is widely recognized for his work on packages like &lt;em&gt;dplyr&lt;/em&gt;, which has become a cornerstone for efficient data manipulation in &lt;em&gt;R&lt;/em&gt;, and for his contributions to &lt;em&gt;Rcpp&lt;/em&gt;, a library that bridges the power of &lt;em&gt;C++&lt;/em&gt; with &lt;em&gt;R&lt;/em&gt; for optimizing &lt;em&gt;R&lt;/em&gt; packages and enhancing performance.&lt;/p&gt;
</content><category term="kernels"/><category term="xeus"/></entry></feed>