You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: jupyter.Rmd
+11-10Lines changed: 11 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,7 @@
4
4
library(magick)
5
5
library(magrittr)
6
6
library(knitr)
7
+
library(fontawesome)
7
8
8
9
knitr::opts_chunk$set(message = FALSE,
9
10
fig.align = "center")
@@ -102,7 +103,7 @@ process.
102
103
To run the a code cell independently, the cell needs to first be activated. This
103
104
is done by clicking on it with the cursor. Jupyter will indicate a cell has been
104
105
activated by highlighting it with a blue rectangle to its left. After the cell
105
-
has been activated (Figure \@ref(fig:activate-and-run-button)), the cell can be run by either pressing the **Run** ($\blacktriangleright$)
106
+
has been activated (Figure \@ref(fig:activate-and-run-button)), the cell can be run by either pressing the **Run** (`r fa("play", height = "11px")`)
106
107
button in the toolbar, or by using a keyboard shortcut of
107
108
`Shift + Enter`.
108
109
@@ -117,7 +118,7 @@ To execute all of the code cells in an entire notebook, you have three options:
117
118
118
119
2. Select **Kernel** >> **Restart Kernel and Run All Cells...** from the menu (Figure \@ref(fig:restart-kernel-run-all)).
119
120
120
-
3. Click the ($\blacktriangleright\blacktriangleright$) button in the tool bar.
121
+
3. Click the (`r fa("fast-forward", height = "11px")`) button in the tool bar.
121
122
122
123
All of these commands result in all of the code cells in a notebook being run.
123
124
However, there is a slight difference between them. In particular, only
@@ -139,8 +140,8 @@ outputs the results. Kernels for many different programming languages have
139
140
been created for Jupyter, which means that Jupyter can interpret and execute
140
141
the code of many different programming languages. To run R code, your notebook
141
142
will need an R kernel. In the top right of your window, you can see a circle
142
-
that indicates the status of your kernel. If the circle is empty ($\bigcirc$),
143
-
the kernel is idle and ready to execute code. If the circle is filled in ($\bullet$),
143
+
that indicates the status of your kernel. If the circle is empty (`r fa("circle", fill = "white", stroke = "black", stroke_width = "10px", height = "11px")`),
144
+
the kernel is idle and ready to execute code. If the circle is filled in (`r fa("circle", fill = "black", stroke = "black", stroke_width = "10px", height = "12px")`),
144
145
the kernel is busy running some code.
145
146
146
147
You may run into problems where your kernel \index{kernel!interrupt,restart} is stuck for an excessive amount
@@ -181,7 +182,7 @@ To edit a Markdown cell in Jupyter, you need to double click on the cell. Once
181
182
you do this, the unformatted (or *unrendered*) version of the text will be
182
183
shown (Figure \@ref(fig:markdown-cell-not-run)). You
183
184
can then use your keyboard to edit the text. To view the formatted
184
-
(or *rendered*) text (Figure \@ref(fig:markdown-cell-run)), click the **Run** ($\blacktriangleright$) button in the toolbar,
185
+
(or *rendered*) text (Figure \@ref(fig:markdown-cell-run)), click the **Run** (`r fa("play", height = "11px")`) button in the toolbar,
185
186
or use the `Shift + Enter` keyboard shortcut.
186
187
187
188
```{r markdown-cell-not-run, echo = FALSE, fig.cap = "A Markdown cell in Jupyter that has not yet been rendered and can be edited.", fig.retina = 2, out.width="100%"}
@@ -201,7 +202,7 @@ By default, all new cells in Jupyter start as code cells, so
201
202
the cell format needs to be changed to be recognized and rendered as a Markdown
202
203
cell. To do this, click on the cell with your cursor to
203
204
ensure it is activated. Then click on the drop-down box on the toolbar that says "Code" (it
204
-
is next to the $\blacktriangleright\blacktriangleright$ button), and change it from "**Code**" to "**Markdown**" (Figure \@ref(fig:convert-to-markdown-cell)).
205
+
is next to the `r fa("fast-forward", height = "11px")` button), and change it from "**Code**" to "**Markdown**" (Figure \@ref(fig:convert-to-markdown-cell)).
205
206
206
207
```{r convert-to-markdown-cell, echo = FALSE, fig.cap = "New cells are by default code cells. To create Markdown cells, the cell format must be changed.", fig.retina = 2, out.width="100%"}
207
208
image_read("img/convert-to-markdown-cell.png") |>
@@ -226,7 +227,7 @@ As you might know (or at least imagine) by now, Jupyter notebooks are great for
226
227
interactively editing, writing and running R code; this is what they were
227
228
designed for! Consequently, Jupyter notebooks are flexible in regards to code
228
229
cell execution order. This flexibility means that code cells can be run in any
229
-
arbitrary order using the **Run** ($\blacktriangleright$) button. But this flexibility has a downside:
230
+
arbitrary order using the **Run** (`r fa("play", height = "11px")`) button. But this flexibility has a downside:
230
231
it can lead to Jupyter notebooks whose code cannot be executed in a linear
231
232
order (from top to bottom of the notebook). A nonlinear notebook is problematic
232
233
because a linear order is the conventional way code documents are run, and
@@ -235,7 +236,7 @@ code is used in some automated process, it will need to run in a linear order,
235
236
from top to bottom of the notebook. \index{Jupyter notebook!best practices}
236
237
237
238
The most common way to inadvertently create a nonlinear notebook is to rely solely
238
-
on using the $\blacktriangleright$ button to execute cells. For example,
239
+
on using the `r fa("play", height = "11px")` button to execute cells. For example,
239
240
suppose you write some R code that creates an R object, say a variable named
240
241
`y`. When you execute that cell and create `y`, it will continue
241
242
to exist until it is deliberately deleted with R code, or when the Jupyter
@@ -288,7 +289,7 @@ We recommend as a best practice to run the entire notebook in a fresh R session
288
289
at least 2-3 times within any period of work. Note that,
289
290
critically, you *must do this in a fresh R session* by restarting your kernel.
290
291
We recommend using either the **Kernel** >>
291
-
**Restart Kernel and Run All Cells...** command from the menu or the $\blacktriangleright\blacktriangleright$
292
+
**Restart Kernel and Run All Cells...** command from the menu or the `r fa("fast-forward", height = "11px")`
292
293
button in the toolbar. Note that the **Run** >> **Run All Cells**
293
294
menu item will not restart the kernel, and so it is not sufficient
294
295
to guard against these errors.
@@ -327,7 +328,7 @@ their computer to run the analysis successfully.
327
328
328
329
2. As you write code in a Jupyter notebook, run the notebook in a linear order
329
330
and in its entirety often (2-3 times every work session) via the **Kernel** >>
330
-
**Restart Kernel and Run All Cells...** command from the Jupyter menu or the $\blacktriangleright\blacktriangleright$
331
+
**Restart Kernel and Run All Cells...** command from the Jupyter menu or the `r fa("fast-forward", height = "11px")`
331
332
button in the toolbar.
332
333
333
334
3. Write the code that loads external R packages near the top of the Jupyter
0 commit comments