|
|
|
@@ -6,11 +6,11 @@ So far you've been using the console to run code. That's a great place to start,
|
|
|
|
knitr::include_graphics("diagrams/rstudio-editor.png")
|
|
|
|
knitr::include_graphics("diagrams/rstudio-editor.png")
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
The script editor is a great place to put code you care about. Keep experimenting in the console, but once you have written code that work and does what you want, put it in the script editor. RStudio will automatically save the contents of the editor when you quit RStudio, and will automatically load it when you re-open. Nevertheless, it's a good idea to regular save your scripts regular and to back them up.
|
|
|
|
The script editor is a great place to put code you care about. Keep experimenting in the console, but once you have written code that works and does what you want, put it in the script editor. RStudio will automatically save the contents of the editor when you quit RStudio, and will automatically load it when you re-open. Nevertheless, it's a good idea to regularly save your scripts and to back them up.
|
|
|
|
|
|
|
|
|
|
|
|
## Running code
|
|
|
|
## Running code
|
|
|
|
|
|
|
|
|
|
|
|
The script editor is also a great place to build up complex ggplot2 plots or long sequences of dplyr manipulations. The key to using the script editor effective is to memorise one of the most important keyboard shortcuts: Cmd/Ctrl + Enter. This executes the current R expression in the console. For example, take the code below. If your cursor is at █, pressing Cmd/Ctrl + Enter will run the complete command that generates `not_cancelled`. It will also move the cursor to the next statement (beginning with `not_cancelled %>%`). That makes it easy to run your complete script by repeatedly pressing Cmd/Ctrl + Enter.
|
|
|
|
The script editor is also a great place to build up complex ggplot2 plots or long sequences of dplyr manipulations. The key to using the script editor effectively is to memorise one of the most important keyboard shortcuts: Cmd/Ctrl + Enter. This executes the current R expression in the console. For example, take the code below. If your cursor is at █, pressing Cmd/Ctrl + Enter will run the complete command that generates `not_cancelled`. It will also move the cursor to the next statement (beginning with `not_cancelled %>%`). That makes it easy to run your complete script by repeatedly pressing Cmd/Ctrl + Enter.
|
|
|
|
|
|
|
|
|
|
|
|
```{r, eval = FALSE}
|
|
|
|
```{r, eval = FALSE}
|
|
|
|
library(dplyr)
|
|
|
|
library(dplyr)
|
|
|
|
@@ -55,7 +55,7 @@ knitr::include_graphics("screenshots/rstudio-diagnostic-warn.png")
|
|
|
|
1. Go to the RStudio Tips twitter account, <https://twitter.com/rstudiotips>
|
|
|
|
1. Go to the RStudio Tips twitter account, <https://twitter.com/rstudiotips>
|
|
|
|
and find one tip that looks interesting. Practice using it!
|
|
|
|
and find one tip that looks interesting. Practice using it!
|
|
|
|
|
|
|
|
|
|
|
|
1. What other common mistakes will RStudio diagonistcs reports? Read
|
|
|
|
1. What other common mistakes will RStudio diagnostics report? Read
|
|
|
|
<https://support.rstudio.com/hc/en-us/articles/205753617-Code-Diagnostics> to
|
|
|
|
<https://support.rstudio.com/hc/en-us/articles/205753617-Code-Diagnostics> to
|
|
|
|
find out.
|
|
|
|
find out.
|
|
|
|
|
|
|
|
|
|
|
|
|