Skip to content

Commit c760794

Browse files
committed
Add gif's for prerequisites page.
1 parent 3e12014 commit c760794

File tree

6 files changed

+46
-6
lines changed

6 files changed

+46
-6
lines changed

analysis/prerequisites.Rmd

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ editor_options:
77
chunk_output_type: console
88
---
99

10-
To get the most out of attending this tutorial, it will help if you have had the
11-
following experiences:
10+
To get the most out of attending this tutorial, it will help if you have previous experience with:
1211

13-
* Analyzed data with R in RStudio
14-
* Knit an R Markdown file in RStudio
12+
* Analyzing data with R in RStudio
13+
* Knitting an R Markdown file in RStudio
1514

1615
## R and RStudio
1716

@@ -21,6 +20,8 @@ RStudio IDE.
2120

2221
[rscloud]: https://rstudio.cloud/
2322

23+
![](assets/rstudio-panes.png)
24+
2425
In the top left is the editor pane. This is where you write your R code that is
2526
saved to files on your computer.
2627

@@ -50,6 +51,19 @@ Plots pane
5051

5152
* Viewer - This displays web content like the HTML created from R Markdown files
5253

54+
A very useful feature for interactively exploring your data while simultaneously
55+
recording your steps is the ability to send lines of code from the file open in
56+
the Editor directly to the R console to be executed. You can do this by clicking
57+
on the button "Run" or using the keyboard shortcut Ctrl/Cmd+Enter.
58+
59+
In the gif below, I demonstrate both methods. First I define the vector `x` by
60+
clicking the "Run" button. Notice how the Environment pane updates with the
61+
newly defined object. Second I use the keyboard shortcut Ctrl+Enter to send the
62+
second line of code to the R console. This plots a histogram of the data, which
63+
is displayed in the Plots pane.
64+
65+
![](assets/rstudio-send-code.gif)
66+
5367
For more information, check out the Software Carpentry lesson on [Introduction
5468
to R and
5569
RStudio](https://swcarpentry.github.io/r-novice-gapminder/01-rstudio-intro/index.html).
@@ -58,7 +72,33 @@ RStudio](https://swcarpentry.github.io/r-novice-gapminder/01-rstudio-intro/index
5872

5973
When you open an R Markdown file in the editor pane, a button named "Knit" will
6074
display. If you click on it, it will knit the document to HTML. You can view the
61-
progress in the newly created "R Markdown" tab in the bottom left. Another
62-
option for running the code is to click on the button "Run". You can run
75+
progress in the newly created "R Markdown" tab in the bottom left.
76+
77+
In the gif below, I click the "Knit" button to knit the R Markdown file. I
78+
include the chunk `Sys.sleep(1)` so that it pauses long enough for you to see
79+
the R Markdown pane appear.
80+
81+
![](assets/rstudio-knit.gif)
82+
83+
Another option for running the code is to click on the button "Run". You can run
6384
individual chunks or "Run All". Furthermore, just like R scripts, you can send
6485
individual lines to the R console with Ctrl/Cmd+Enter.
86+
87+
In the gif below, I execute all the code chunks by clicking "Run All". Note that
88+
before I do this, I instruct RStudio to send the chunk output to the R console
89+
instead of displaying it inline. This makes it easier to interactively develop
90+
the code in the R console and keeps the file uncluttered.
91+
92+
![](assets/rstudio-run-all.gif)
93+
94+
Lastly, it is important to understand how to interpret the error messages
95+
produced when knitting R Markdown files, which you will use during the tutorial.
96+
97+
In the gif below, I knit an R Markdown file that produces an error trying to run
98+
`log("a")`. The default view only displays the error message. I click on
99+
"Output" to see the full log. This informs you the lines in the source R
100+
Markdown file to check for the error. Importantly, it doesn't pinpoint the exact
101+
line where the error occurred. Instead it reports the range of lines spanned by
102+
the code chunk where the error occurred.
103+
104+
![](assets/rstudio-knit-error.gif)

docs/assets/rstudio-knit-error.gif

203 KB
Loading

docs/assets/rstudio-knit.gif

233 KB
Loading

docs/assets/rstudio-panes.png

114 KB
Loading

docs/assets/rstudio-run-all.gif

317 KB
Loading

docs/assets/rstudio-send-code.gif

196 KB
Loading

0 commit comments

Comments
 (0)