An Introduction R
Preface
0.1
The aim of this book
0.2
Who is this book for?
0.3
How to use this book
0.4
Book website
0.5
Some R pointers
0.6
License
1
Getting started with R and RStudio
1.1
Installing R
1.1.1
Windows users
1.1.2
Mac users
1.1.3
Linux users
1.1.4
Testing R
1.2
Installing RStudio
1.2.1
Windows and Mac users
1.2.2
Linux users
1.2.3
Testing RStudio
1.3
RStudio orientation
1.3.1
Console
1.3.2
Environment/History/Connections
1.3.3
Files/Plots/Packages/Help/Viewer
1.4
Alternatives to RStudio
1.4.1
Advanced text editors
1.4.2
Integrated developement environements
1.5
R packages
1.5.1
CRAN packages
1.5.2
Bioconductor packages
1.5.3
GitHub packages
1.5.4
Using packages
1.6
Projects in RStudio
1.7
Working directories
1.8
Directory structure
1.9
File names
1.10
Project documentation
1.11
R style guide
1.12
Backing up projects
1.13
Citing R
1.14
Exercise 1
2
Some R basics
2.1
Getting started
2.2
Objects in R
2.2.1
Creating objects
2.2.2
Naming objects
2.3
Using functions in R
2.3.1
Pipes. A better way!!!!!
2.4
Working with vectors
2.4.1
Extracting elements
2.4.2
Replacing elements
2.4.3
Ordering elements
2.4.4
Vectorisation
2.4.5
Missing data
2.5
Getting help
2.5.1
R help
2.5.2
Other sources of help
2.6
Saving stuff in R
2.7
Exercise 2
3
Data in R
3.1
Basic Data types
3.2
Complicated Data Types
3.2.1
Dealing with Date and Time
3.2.2
Factors
3.3
Data structures
3.3.1
Scalars and vectors
3.3.2
Matrices and arrays
3.3.3
Lists
3.3.4
Data frames
3.4
Importing data
3.4.1
Saving files to import
3.4.2
Import functions
3.4.3
Common import frustrations
3.4.4
Other import options
3.5
Wrangling data frames
3.5.1
Positional indexes
3.5.2
Logical indexes
3.5.3
Adding columns and rows
3.6
Summarising data frames
3.7
Exporting data
3.8
Exercise 3
4
Tidyverse
4.1
Data Frames & Tibbles
4.2
Reading external data
4.3
Wrangling Data
4.4
Relational Data
4.5
Exercise 4
5
Graphics with ggplot
5.1
Beginning at the end
5.2
The start of the end
5.2.1
The purest of ggplots
5.2.2
Wrapping grids
5.2.3
Plotting multiple ggplots
5.2.4
Make it your own
5.2.5
Setting the theme
5.2.6
Prettification
5.3
Tips and tricks
5.3.1
Statistics layer
5.3.2
Axis limits and zooms
5.3.3
Layering layers
5.3.4
Continuous colours
5.4
Exercise 5
6
Programming in R
6.1
Functions in R
6.2
Conditional statements
6.3
Combining logical operators
6.4
Loops
6.4.1
For loop
6.4.2
While loop
6.4.3
When to use a loop?
6.4.4
If not loops, then what?
6.5
Exercise 6
Appendix
A
Installing R Markdown
A.1
MS Windows
A.2
Mac OSX
B
Reproducible reports with R markdown
B.1
What is R markdown?
B.2
Why use R markdown?
B.3
Get started with R markdown
B.4
Create an R markdown document
B.5
R markdown anatomy
B.5.1
YAML header
B.5.2
Formatted text
B.5.3
Code chunks
B.5.4
Adding figures
B.5.5
Adding tables
B.5.6
Inline R code
B.6
Some tips and tricks
B.7
Further Information
C
Version control with Git and GitHub
C.1
What is version control?
C.2
Why use version control?
C.3
What is Git and GitHub?
C.4
Getting started
C.4.1
Install Git
C.4.2
Configure Git
C.4.3
Configure RStudio
C.4.4
Register a GitHub account
C.5
Setting up a project in RStudio
C.5.1
Option 1 - GitHub first
C.5.2
Option 2 - RStudio first
C.6
Using Git
C.6.1
Tracking changes
C.6.2
Commit history
C.6.3
Reverting changes
C.6.4
Collaborate with Git
C.6.5
Git tips
C.7
Further resources
Published with bookdown
An Introduction to R
An Introduction to R
Nikhil Kaza
August 20, 2022
Preface