R Step-by-Step with Jupyter

Suppose you have an R script that you would like to debug, or step through line by line collaboratively with others.

You can do this using a Jupyter notebook and CoCalc’s built-in collaboration. Start by using the jupytext command to convert a script to blocks of code in cells in a notebook.

If your R script is rscript.R, then do the following:

  1. Upload rscript.R to a CoCalc project.

  2. Open a terminal and run the commands:

    jupytext rscript.r --to ipynb
    open rscript.ipynb
    
  3. In the Jupyter notebook, select the “R (system-wide)” kernel. You will see the script separated into multiple cells in the notebook.

You can then step through the script by running one cell in the notebook at a time.