Very brief RStudio orientation

This commit is contained in:
hadley 2015-12-08 06:53:57 -06:00
parent cc4c43e367
commit 27b148d9ea
3 changed files with 29 additions and 15 deletions

View File

@ -102,6 +102,35 @@ To run the code in this book, you will need to install both R and the RStudio ID
1. Download R and install R, <https://www.r-project.org/alt-home/>.
1. Download and install RStudio, <http://www.rstudio.com/download>.
1. Install needed packages (see below).
### RStudio
RStudio is an integated development environment, or IDE, for R programming. There are three key regions:
`r bookdown::embed_png("screenshots/rstudio-layout.png", dpi = 220)`
You run R code in the __console__ pane. Textual output appears inline, and graphical output appears in the __output__ pane. You write more complex R scripts in the __editor__ pane.
There are three keyboard shortcuts that we strongly encourage that you learn because they'll save you so much time:
* Cmd + Enter: sends current line (or current selection) from the editor to
the console and runs it.
* Tab: suggest possible completions for the text you've typed.
* Cmd + ↑: in the console, searches all commands you've typed that start with
those characters.
If you want to see a list of all keyboard shortcuts, use the meta keyboard shortcut Alt + Shift + K: that's the keyboard shortcut to show all the other keyboard shortcuts.
We strongly recommend making two changes to the default RStudio options:
`r bookdown::embed_png("screenshots/rstudio-workspace.png", dpi = 220)`
This ensures that every time you restart RStudio you get a completely clean slate. This is good pratice because it encourages you to capture all important interactions in your code. There's nothing worse than discovering three months after the fact that you've only stored the results of important calculation in your workspace, not the calculation itself in your code. During a project, it's good practice to regularly restart R either using the menu Session | Restart R or the keyboard shortcut Cmd + Shift + F10.
### R packages
You'll also need to install some R packages. An R _package_ is a collection of functions, data, and documentation that extends the capabilities of base R. Using packages is key to the successful use of R. To install all the packages used in this book open RStudio and run:
@ -124,21 +153,6 @@ library(tidyr)
You will need to reload the package every time you start a new R session.
### RStudio
Brief RStudio orientation (code, console, and output). Pointers to where to learn more.
Important keyboard shortcuts:
* Cmd + Enter: sends current line from editor to console.
* Tab: suggest possible completions for the text you've typed.
* Cmd + ↑: in the console, searches all commands you've typed that start with
those characters.
* Cmd + Shift + F10: restart.
* Alt + Shift + K: the keyboard shortcut that shows all the keyboard shortcuts.
Note about turning on save/load session off.
## Getting help
* Google. Always a great place to start! Adding "R" to a query is usually

Binary file not shown.

After

Width:  |  Height:  |  Size: 585 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 554 KiB