# The Bill but in RStudio


Find this notebook on the web at
<a class="quarto-xref" href="https://resampling-stats.github.io/edition-3-r/about_technology.html#nte-bill_in_rstudio">Note <span>4.4</span></a>.

Notice that the Download link gave you a file ending in `.Rmd`, where
“Rmd” is short for *RMarkdown*. *RMarkdown* is the name of the notebook
format — and it is the native notebook format for RStudio. The `.Rmd`
file is an RMarkdown version of the notebook.

Open the `bill_in_rstudio.Rmd` file in RStudio.

RStudio’s idea of a notebook is very similar to Jupyter’s — and this is
not a coincidence, the Jupyter notebook was already popular when RStudio
came up with its own take on this idea.

However, there are some differences between Jupyter and RStudio in the
way that they think about notebooks, and in the notebook interface.

To start with the interface, notice that RStudio has its own menu, with
“File”, “Edit”, etc. Each notebook has its own tab in the interface. If
you have just opened this notebook, and no others, you will only have
one tab, corresponding to this notebook. Depending on your
configuration, you may also have other windows inside the RStudio
window, for example, showing the variables defined in R, and the files
in the same directory as the notebook.

Identify the notebook tab — the tab containing this file. You will
notice that the notebook tab has a *notebook toolbar* at the top. We
will come to that soon.

We have started with the interface, but now we return to RStudio’s
slightly different concept of a notebook, compared to Jupyter.

For example, Jupyter thinks in terms of *cells*. All content in a
Jupyter notebook has a containing cell; text cells contain text, and
code cells contain code. In a Jupyter notebook, this text would be
inside a text cell.

RStudio notebook thinks of the notebook differently. It conceives of the
notebook as being text, by default. Within the text, there may be *code
chunks*. These are the equivalent of Jupyter’s code cells — they are
blocks of code you can execute within the notebook. The notebook
interface displays any output from the code, including plots.

For example, the following is a *code chunk* (in RMarkdown terms):

```{r}
# The cost of Alex's meal.
# alex_meal gets the value 10.50
alex_meal <- 10.50
# Display the cost of Alex's meal.
alex_meal
```

Now we return to the interface. Click inside the code chunk above.
Notice that the code chunk is grey, compared to the usual default white
for the rest of the notebook. At the top left of the code chunk, you
will see a *play* icon. Click this to run the code and see the results.

There are various other ways of running code chunks. For example, the
*notebook toolbar* that you identified about has icons that allow you
run the code. In particular, there is a “Run” icon that triggers a
drop-down menu, with options for running this and other code chunks. You
will soon find yourself wanting the keyboard shortcuts to run
code-chunks — please do start using these as early as you can — you will
find they make you much more efficient and fluent in using notebooks in
RStudio. To see the shortcuts, find the main RStudio menu, and select
“Keyboard Shortcuts Help” for more information.

We will leave you with this brief introduction, and point you out to the
interwebs to search for good tutorials on using RStudio. Books go out of
date quickly, so we won’t risk instant obsolescence by recommending
particular pages or videos here.
