R and RStudio Cheatsheet

Preliminaries

Load package

Load Data

Data from package
Data Import
  • Upload local file or use a URL
  • File > Import > Dataset > From …
  • Add import code to code chunk (exclude the View command)

Data Viewer

Order rows
  • Click on column heading
  • Click again to change direction
Filter
  • Click Filter button on top left of viewer
  • Use controls below column headings
Search
  • Use the search box in top-right

RMarkdown Basics

Main section

## Heading here

Subsection

### Heading here

Italic

*text here*

Bold

**text here**

Numbered List

1. text here

Unnumbered List

- text here

Blockquote

> text here

Summaries

Numerical Variable

favstats
median etc

Categorical Variable

frequency
relative frequency

Two Variables

Crosstabs
Correlation

Graphs

One Variable

Pie Chart
Histogram
Barchart
Labeled Dotplot

Two Variables

100% Stacked Barchart
Scatterplot
Boxplot

Three Variables

Paneled Scatterplot

Colors

list by name
palette list
pick a palette
add in graph

Graph Labeling

main title
axis labels

Misc

Linear Modeling

add to graph
get model
diagnostics