RStudio

Keyboard Shortcuts

You can find shortcuts in the dropdown menu “Help” -> “Keyboard Shortcuts Help”, or online

I want to draw your attention to these shortcuts, in particular, as they are use quite often:

Description Windows Mac
Keyboard help Alt+Shift+k option+Shift+k
Insert assignment operator <- Alt+- option+-
Insert pipe operator %>% Ctrl+Shift+m Cmd+Shift+m
Insert multiple cursors Ctrl+Alt+ L Mouse Ctrl+option+ L Mouse
Insert code chunk {r} Ctrl+Alt+ i Ctrl+option+ i
Comment out lines # Ctrl+Shift+c Cmd+Shift+c
Search active document Ctrl+f Cmd+f

RMarkdown

RMarkdown documents begin with a yaml header which passes arguments to pandoc (the program that creates the document). The options that can be specified in the yaml header are document-specific. Some arguments that exist for all types of documents include title, author, date, and output.

Overview

You can see a cheatsheet for RMarkdown under “Help” -> “Cheetsheets” -> “R Markdown Cheetsheet”.

Some useful things to know:

  • Enclosing text in single * italicizes
  • Enclosing text in double * bolds
  • Enclosing text in triple * bold italics
  • Prefacing something with a \ means “do not evaluate”

  • Adding a break between lines starts a new paragraph

  • Enclosing text in backticks ` code formats
  • Starting text with a > creates a…

…block quote paragraph that can span multiple lines

  • Enclosing text with ^ creates a superscript2
  • Enclosing text with ~ creates a subscript2
  • Enclosing text with double ~~ creates a strikethrough

  • Code in RMarkdown is wrapped in three backticks ` followed at the beginning by {r}

```{r}

Code would go here.

```

  • Code in-line is inserted with one backtick `
  • Enclosing text with brackets “[” and then “(” links to other websites/documents
  • Starting text with - creates a bulleted list
    • Indenting four spaces and then using - creates a sub-bullet
  • Starting text with a number and period (1.) creates an ordered list
    1. My point 1
    2. My point 2
  • Starting text with up to six # creates differently formatted headers:

Header I

Header II

Header III

Header IV

Header V
Header VI

Header VII (does not work)

  • Placing an image is done by starting with a !
    • The path can either be a local path or a website

Just an image:

You can resize an image by including curly brackets { at the end and a height/width specifer within them (e.g., width=50%):

Copyright © Penn State Psychology. All rights reserved.