pythonrjupyter-notebookpackagejupyter-irkernel

Equivalent of autoreload for R jupyter notebook


I am working in a jupyter notebook with the irkernel. When I do the same with a Python kernel I usually have at the top of my notebooks the instructions

%load_ext autoreload

%autoreload 2

If I modify a source code that the notebook imports or uses then those functions and pieces of code in the notebook that use that source code will be automatically updated. Is there an equivalent for this in a jupyter R notebook?

I am using a local package that my notebook uses. I would like to be able to edit the package and have the modifications automatically loaded in my notebook.


Solution

  • In short? Unless jupyter does something that is impossible while working in base R the answer is "No". R cannot dynamically load packages for editing in a similar fashion to how Python does it. The recommended method in R is to modify, install and often run R CMD check. I am not sure how Jupyter implements these, but this is the approach that is also focused upon in the user experience of Rstudio.

    Hadley has great (free!) book on how to develop packages in R. I am almost certain he mentions this workflow somewhere in the "Getting started" section.