@@ -32,7 +32,30 @@ 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. Click the Knit button to re-run the analysis and find the first issue.
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
58
+ file where the error occurred.
36
59
37
60
## File paths
38
61
0 commit comments