Organize yourself in RStudio
1 Jupyter hub at our department’s server
Work in your web browser, URL below.
Use your individual user name and password.
AIC is the name of the server. UFAL is the name of our department. MFF stands for faculty. CUNI.CZ stands for Charles university in Czechia. JLAB is the name of this service.
2 Select RStudio
Hit the RStudio tile marked with a green scribble square. The other tiles would take you to different programming languages. There are also two tiles with the icon of the R programming language. They would run the bare R console for you. Programmers like it, but we would rather stick to the polished GUI of RStudio.
If you want to have it locally, install it from RStudio’s web https://posit.co/products/open-source/rstudio/?sid=1. It will tell you to download and install the bare R first, from the Comprehensive R Archive Network https://cran.r-project.org/ .
3 Files in RStudio
In the top Menu
, Select File
> New
. You will get a choice from a number of formats. I write this with the Quarto tool and choose Quarto presentation
. Another option is Quarto document
. It is no big deal which you choose. Both are plain text files.
4 Quarto Editor Options: Visual
- many formatting options as buttons
- document displays as a rich text, even with images inserted.
5 Quarto Editor Options: Source
Displays strictly plain text
You must format everything manually.
The basic formatting is done with markdown tags. You see a Level-2 Heading made with ##
and space and a URL link. For the fastest reference, go to RStudio’s Menu bar and hit Help > Markdown Quick Reference
. Look to the right bottom pane of RStudio. There are tabs Files
, Plots
, Packages
, Help
, Viewer
, and Presentation
. You will see the Markdown Quick Reference
in the Help
tab. But the little markdown you need you can absorb by reading the .qmd
file of this document with the Source view on.
6 YAML header
File
YAML_header_multiformat
Copy-paste it into your new file to get the same formatting you see here.
Keep files
atrium.css
andatrium.tex
in the same folder!!!
---
title: "Organize yourself in RStudio"
echo: true
format:
revealjs:
notes: true
css: atrium.css
pdf:
include-in-header: atrium.tex
html:
css: atrium.css
---
What makes plain text files real Quarto files is a piece of plain text metadata in the beginning: the YAML header, which you can overwrite.
YAML is not part of R and you will be perfectly fine without it in this course. Here are easy-to-read references to YAML, should you really crave for more:
Quarto has introduced a set of attributes and values in YAML. Here you see some of them. Some attributes explained:
echo: true
When you render the document (i.e. typeset the document for printing), also display executable code snippets.format: revealjs, pdf, html
(watch out for the indentation!): you can render it in these three formats.revealjs
are dynamic html slides as you see them in this presentation. Each format is specified with more fine-grained attributes. We are not going to delve into this. You can read the Quarto user guide and experiment yourself to become an expert.
7 CSS file
Format template for HTML pages, not R-specific.
Main purpose of
atrium.css
: larger font in code snippetsNo
atrium.css/.tex
in YAML header ⟾ Quarto defaultMy YAML header contains references to styling files for html (
atrium.css
) and LaTeX (atrium.tex
), mainly to make code snippets more legible on slides and to prevent code spilling over the margin in LaTeX (PDF).Generally, you should do fine without
.css
and.tex
files like this, because the Quarto defaults are reasonable.
8 Understand note taking with these teaching materials
Render your source
.qmd
files to PDF, HTML,MS Wordhttps://quarto.org/docs/presentations/revealjs/
Render
button produces the document in the format you have specified in the YAML header as format
..qmd
is not very pretty for sharing. You should render it for print or web. Available document formats are PDF, HTML, and MS Word. The last one is not going to work here on the cloud because it needs MS Word locally installed and AIC Jupyterlab is a Linux machine.
Another option is rendering it as revealjs
slides. revealjs is a Java format based on HTML. It creates dynamic presentations that open in the web browser. It is a different file from the HTML file you get when you render qmd as HTML. In fact, you have to render it live from the source every time you want to run the slide show.
The revealjs
slide show enables speaker view, export to pdf, and many other widgets, if you list them in the YAML header. Render one of my source files as a slide show and explore it. And here is the user guide for revealjs
Quarto presentations: https://quarto.org/docs/presentations/revealjs/ .
Find Settings, hit e
as Export to PDF mode
and you will get all slides (without speakers notes). Then find Print
in the browser menu and send it to a printer or to PDF to get a PDF file. Anyway, if you want all this accompanying text along, then you are better off rendering this directly as PDF.
9 Resume broken connection
Normally you will see RStudio right after the start, but sometimes the server says it is not running. Then hit the Launch Server button. Also, when you stay idle for a long time, the server will stop (1,000 seconds by default).
When the connection is broken, you will not be able to save or edit your files. Hit Refresh
in your browser to invoke this page and relaunch the server.
10 Control RStudio’s behavior
11 Check autosaving options
12 Control character encoding
13 Soft-wrap code
You will be able to see the entire line even if you narrow your browser window.
14 Control text in .qmd/.Rmd
documents
Soft-wrap text lines.
Display inserted figures in the editor (before rendering).
.qmd/.Rmd
documents, you have to adjust some options in a separate menu.