Toolbox
The toolbox contains a collection of nifty tips, tricks and hacks for anything R.
Keyboard shortcuts to make your life easier
| Function | Shortcut PC / Mac |
|---|---|
| Run current line | Ctrl + Enter / Cmd + Return |
| Add <- | Alt + - / Option + - |
| Add %>% | Ctrl + Shift + M / Cmd + Shift + M |
| Show help | F1 |
| Options for auto-fill | Tab |
| Create New Script | Ctrl + Shift + N / Cmd + Shift + N |
| Comment out line | Ctrl + Shift + C / Cmd + Shift + C |
| Save your script | Ctrl + S / Cmd + S |
Reading in Data
| Data Source | R command |
|---|---|
| WEXTOR (CSV) | readr::read_delim("data.csv", delim = ";") |
| Excel (XLSX) | xlsx::read.xlsx("data.xlsx", sheetIndex = 1) |
| R Data Source (RDS) | readRDS("data.Rds") |
| SPSS (SAV) | foreign::read.spss("data.sav") |
Logic
| Symbol | Meaning |
|---|---|
| < | smaller than |
| <= | smaller or equal |
| > | greater than |
| >= | greater or equal |
| == | equal to |
| != | unequal to |
| TRUE | true (also written T) |
| FALSE | false (also written F) |
tidyselect::between(x, left, right) |
is x between the left and right value? |
tidyselect::contains(match) |
selects columns whose names contain a word (to be used with dplyr::select()) |
| & | AND (both must be TRUE) |
| | | OR (just one must be TRUE) |
| ! | NOT (as in != NOT equal) |
Most important dplyr functions
select(): select certain columns by namefilter(): filter values from a column/variablerename(): rename a variablemutate(): change values of a column (new or existing)%>%: "pipe" brings data from previous operation to the next (Shortcut: Strg + Shift + M)
Incomplete List of Useful Packages
| Package Name | General Purpose |
|---|---|
| psych | Advanced statistical testing / modeling e.g. factor analysis |
| tibble | Alternative for creating data frames |
| tidyr | Clean up data & simple reshaping |
| dropR | Dropout analysis (by experimental condition) |
| foreign | Handling data from SPSS |
| corrplot | Create correlation plots/ matrices |