Preface

My other post describes using Conda installing R kernel Notebook on a Linux remote server, but I’ve found that conda doesn’t handle various dependency conflicts very well, often resulting in installations that don’t I found that conda doesn’t handle dependency conflicts well, which often leads to unsuccessful installations.

Later, I also used brew to install it on my macOS system, and found that it was easier and faster, so I summarized the steps.

System: macOS Venture 13.1 (22C65)

Product: Intel Chip MacBook

Requirement

Install Homebrew.

Homebrew is the most used package manager on macOS, and this is its official installation tutorial. But usually, we just need to enter the following command while making sure the network is accessible:

1
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

R

It is so easy to install r package with brew:

1
brew install r

Jupyter

Almost the same as before:

1
brew install jupyterlab

R-Kernel

Use r to install IRkernel:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# Go to the r console first
R
# Install devtools
install.packages('IRkernel')
# At this point you might be asked to choose a mirror, just choose the nearest one
# Register the kernel with R
IRkernel::installspec()
# Install the RStudio shortcut.
# If RStudio is installed, you can choose to install it, but not if you're using a notebook.
jupyter labextension install @techrah/text-shortcuts

Launch Notebook

1
jupyter notebook

Click Create or New button and find that you can create r-kernel notebooks now.

Landscaping

This part is not necessary and is for record only.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# Configure themes
pip install jupyterthemes
# A set of theme settings that I personally like and have gotten used to
jt -t monokai -f fira -fs 13 -cellw 90% -ofs 11 -dfs 11 -T -N
# Restore the default theme
jt -r
# Configure plugins
pip install jupyter_contrib_nbextensions
jupyter contrib nbextension install --user
# Install the plugin manager This step may fail See update 1 later for details
pip install jupyter_nbextensions_configurator
# Suggested configuration items
# Hinterland code completion
# Collapsible headings
# Notify Notify mechanism to run time-consuming tasks and notify when they're done.
# zenmode Hide active status bar, easy to notice the code.
# ExecuteTime Show execution time

Postscript

I didn’t run into any snags with this installation, so if you run into any other issues, feel free to leave them in the comments section.

Update 1

When I repeated this tutorial on 2023.03.20, I found that the Nbextensions tag would not appear. Upon checking, this was caused by the plugin not being updated to adapt a new version of the dependency package nbclassic.

See the GitHub issue for details.

Solution: Downgrade the dependency package. We may update it later.

1
pip install "nbclassic<0.5"

Update 2

2024.03.15 Update: The notebook was officially upgraded to version 7.x a couple months back. I haven’t had to do any 3rd party manipulation with the new version. It can be changed directly inside the settings with a high degree of customization.

notebook-setting