@@ -32,15 +32,31 @@ steps:
32
32
33
33
The analysis purposefully contains various issues that make it difficult to
34
34
reproduce. Open the file ` spotify.Rmd ` by clicking on it in the RStudio Files
35
- pane.
36
-
37
- Next click the Knit button to re-build the document. The code fails
38
- due to an error. Click on "Output" to see the lines in the Rmd
35
+ pane. In the Editor pane, click on "Run" and then click on "Run All" to execute
36
+ all the code chunks in the R console (Ctrl/Cmd+Alt+Enter). Note that the code
37
+ completes and produces a plot in the Plots pane.
38
+
39
+ Next click the Knit button to re-build the document. This time the code fails
40
+ due to an error. The difference is because RStudio knits Rmd files in a clean
41
+ R session. In contrast, the R session currently running in the R console already
42
+ had all the analysis variables created because the workspace was restored. This
43
+ is why you want to avoid saving your workspace: it can make it appear that your
44
+ code is running when it is actually contains errors. In fact, if you scroll
45
+ back up through the R console history, you'll see that some errors did occur.
46
+ But the analysis still completed since the intermediate objects were already
47
+ available.
48
+
49
+ To fix the workspace issue, first go to the Files pane and delete the file
50
+ ` .RData ` that contains the saved workspace. Second, go to "Tools" -> "Global
51
+ Options...". Unclick the checkbox "Restore .RData into workspace at startup" and
52
+ change the dropdown "Save workspace to to .RData on exit" to Never.
53
+
54
+ ![ ] ( assets/rstudio-workspace.png )
55
+
56
+ Now you can proceed to fix the analysis one error at a time. Click on Knit to
57
+ produce the first error. Then click on "Output" to see the lines in the Rmd
39
58
file where the error occurred.
40
59
41
- Working together in small groups, reproduce the analysis by fixing the errors.
42
- Below are hints on how to fix each error you will find.
43
-
44
60
## File paths
45
61
46
62
The first error you will encounter is below:
0 commit comments