A travel guide to the R universe
Preface
1
What is R and why use it?
1.1
How do we typically use software in science?
1.2
What does R do?
1.3
Why use R
1.4
Who uses it?
1.5
R and computational reproducibility
1.6
Alternatives to R
2
Some things to know about R & the R learning ecosystem
3
R Idioms
3.1
Quickstart Guide to R
4
Quickstart guide to learning R coding
5
RStudio Cloud
5.1
RStudio Cloud Installation Video
5.2
RStudio Cloud Primers
6
Hello R! A first encounter with data visualization
6.1
Key Ideas
6.2
Data in R
6.3
Loading data that comes with R
6.4
Plotting simple datasets with
plot()
6.5
Commands in R
6.6
The structure of commands in R
6.7
Arguements in R
6.8
Arguements and more arguments
6.9
Multiple arguments at the same time
6.10
R commands and line breaks
6.11
Code comments
6.12
A note on plotting
6.13
Now you try it
6.13.1
Easy tasks
6.13.2
Intermediate tasks
7
Troubleshooting problems w/ RStudio Cloud
8
swirl
8.1
swirl quickstart:
8.2
Installing Packages in RStudio & RStudio Cloud
8.3
Getting to know swirl video
8.4
A worked example of swirl “Sequences of Numbers”
9
A guide to current swirl tutorials
9.1
Regression Models: The basics of regression modeling in R (Team swirl)
9.2
Statistical Inference: The basics of statistical inference in R (Team swirl)
9.3
Exploratory Data Analysis: The basics of exploring data in R (Team swirl)
9.4
Getting and Cleaning Data (Team swirl)
9.5
Advanced R Programming (Roger Peng)
9.6
The R Programming Environment (Roger Peng)
9.7
Regular Expressions (Jon Calder)
9.8
A (very) short introduction to R (Claudia Brauer)
9.9
R Programming: The basics of programming in R (team swirl)
10
R Desktop
10.1
Important notes
10.2
Videos
11
RStudio Desktop
12
A note before you start - make sure you’re not in OneDrive or another network folder!
13
The layout of RStudio
13.1
RStudio (Desktop or Cloud)
13.2
R emulators
13.3
Other ways
13.4
RStudio at a glance
13.4.1
The console versus the script editor
14
Problems getting R and RStudio up and running
14.1
Solution 1: Use RStudio Cloud (short-term solution)
14.2
Solution 2: Use the base R program (medium-term solution)
14.3
Solution 3: Update an old version of R
14.4
Solution 3: Address common problems
14.5
Solution 4: See the full Troubleshooting Guide
15
Troubleshooting R error messages
15.1
Acting weird but not telling you something is wrong
15.2
Warning messages
15.3
Error messages
15.4
Crashes
16
Note on updating R (read if you’ve used R before!)
17
Advanced Troubleshooting R & RStudio Installation
18
Video - Angry red text in R (don’t panic!)
19
Troubleshooting R & RStudio Installation
20
Rtools
21
Troubleshooting basic problems
21.1
Bad arguments
21.2
Hung code
21.3
Missing quotes
22
Downloading R packages (and their data)
22.1
Loading data from R packages
22.1.1
Functions & Arguements
22.2
OPTIONAL: What functions come with base R?
22.3
Load data from an external R package
22.3.1
Step 1: Downloading packages
install.packages(...)
22.3.2
Step 2: Explicitly loading a package
22.4
OPTIONAL: Seeing all of your installed packages
22.5
Downloading packages using RStudio
22.6
Your turn
23
Intalling R packages
24
“Libaries” versus “packages” in in R
25
Ways of getting data into R
26
Loading Excel spreadsheets into RStudio
26.0.1
Prepping data in Excel
26.1
Preparing a file for loading into R
26.2
Reload data
27
Loading data from .csv files into RStudio
27.1
Introduction
27.1.1
Learning goals
27.1.2
Learning objectives
27.1.3
R packageas
27.1.4
R commands
27.1.5
Files
27.1.6
Potential Hangups
27.1.7
References
27.2
Preliminary step: download a .csv file
27.3
Set the “working directory” (“WD”) in RStudio
27.4
Check the working directory with getwd()
27.5
Check for the file you downloaded with list.files()
27.6
OPTIONAL Interacting with R via the console or the source viewer
27.7
Loading data into R using read.csv()
27.7.1
Load data into an R “object”
27.7.2
The assignment operator “<-”
27.8
Optional: Plot the Mendley 1998 data
27.9
Loading .csv files using RStudio [ ]
27.10
Challenge
28
Interactive resources for learning R
28.1
RStudio Cloud Primers (FREE! Total beginners).
28.2
swirl Interactive Primers
28.2.1
swirl quickstart:
29
R Learning Books
29.1
Learning R for Bioinformatics
29.2
Learning R for Statistics
29.3
Learning how to load data into R
29.4
Resources for those with some background in statistics, data analysis or programming
29.4.1
Learning R for Ecological Statistics
29.4.2
Learning R for general “data science”
29.5
Resources for those interested in programming
29.5.1
Learning R for programming/modeling
29.5.2
Learning R for programming
29.5.3
Learning R for Epidemiological modeling
30
RStudio videos
30.1
Basic
30.2
Intermediate
30.3
Intermediate-Advanced
30.4
Other interesting videos
31
Appendix: RMarkdown
31.1
Key features of RMarkdown: heading tags and code chunks:
31.2
Code chunks
31.2.1
Code chunk tags
31.2.2
Code chunk controls
31.2.3
Source viewer controls
31.2.4
Running code in code chunks
31.2.5
Running multiple chunks
31.2.6
Headers
31.3
Other key features of RMarkdown
31.3.1
The “YAML” Header
31.3.2
Knitting
31.4
Markdown syntax
32
Getting set up for rendering RMarkdown documents
33
The different faces of R code: The console, scripts & RMarkdown
33.1
The console
33.2
Scripts
33.2.1
Creating scripts
33.2.2
Running code from a script
33.2.3
Running code with keyboard shortcuts
33.3
Organizing scripts
33.3.1
What to include in a script
33.3.2
Formatting sections in R scripts
33.3.3
A sample R script
33.3.4
A polished R script
33.4
RMarkdown
34
Goind deeper with functions and arguments
35
R’s Installation directory and “working directory”
36
Understanding data helpfiles
Published with bookdown
Get R Done! A travelers guide to the world of R
Chapter 36
Understanding data helpfiles