The Comprehensive Guide to R Programming
Preface
Open Source
Flexibility
Community
1
Installing the Data Science Toolchain
1.1
Installing On Windows Machines
1.1.1
Install The R Environment
1.1.2
Install R Packages
1.1.3
Install RStudio
1.1.4
Install LaTeX
1.1.5
Install Rtools
1.1.6
Create a GitHub Account
1.1.7
Install & Configure Git
1.1.8
Create & Link an R-Project
1.2
Installing On Mac/Apple Machines
1.2.1
Install The R Environment
1.2.2
Install R Packages
1.2.3
Install RStudio
1.2.4
Install LaTeX
1.2.5
Create a GitHub Account
1.2.6
Install & Configure Git
1.2.7
Create & Link an R-Project
2
Introduction To Using R
2.1
Assigning values to objects
2.1.1
The assignment operator
2.1.2
Naming convention for R objects
2.2
Function basics
2.2.1
Evaluating functions
2.3
Working with packages
2.3.1
Installing Packages
2.3.2
Loading Packages
2.3.3
Getting help with packages (from within R)
2.3.4
Getting help with packages (from the web)
2.3.5
Finding useful packages
2.4
Style guide
2.4.1
Notation and naming
2.4.2
Organization
2.4.3
Syntax
2.5
Workspace
2.5.1
Working Directory
2.5.2
Environment Objects
2.5.3
Command History
2.5.4
Saving and loading your workspace
2.5.5
Workspace Options
2.5.6
Shortcuts
3
Managing your workflow
3.1
R Projects
3.1.1
Creating Projects
3.1.2
So What’s Different?
3.2
R Markdown
3.2.1
Creating an R Markdown File
3.2.2
Components of an R Markdown File
3.2.3
YAML Header
3.2.4
Knitting the R Markdown File
3.2.5
Additional Resources
3.3
R Notebook
3.3.1
Creating an R Notebook
3.3.2
Interactiveness of an R Notebook
3.3.3
Saving, Sharing, Previewing & Knitting an R Notebook
3.3.4
Additional Resources
4
Data Types
4.1
Dealing with Dates
4.1.1
Getting current date & time
4.1.2
Converting strings to dates
4.1.3
Convert Strings to Dates
4.1.4
Create Dates by Merging Data
4.1.5
Extract & manipulate parts of dates
4.1.6
Creating date sequences
4.1.7
Calculations with dates
4.1.8
Dealing with time zones & daylight savings
4.1.9
Additional resources
4.2
Character String Basics
4.2.1
Creating Strings
4.2.2
Converting to Strings
4.2.3
Printing Strings
4.2.4
Counting string elements and characters
4.2.5
String Manipulation with Base R
4.2.6
Simple Character Replacement
4.2.7
String manipulation with the stringr package
4.2.8
Set Operations for Character Strings
4.2.9
Sorting a String
4.3
Dealing with Factors
4.3.1
Creating, Converting & Inspecting Factors
4.3.2
Ordering, Revaluing, & Dropping Factor Levels
4.4
Dealing with Logicals
4.5
Dealing with Regular Expressions
4.5.1
Regex Syntax
4.5.2
Regex Functions in Base R
4.5.3
Regex Functions with
stringr
4.5.4
Detecting Patterns
4.5.5
Additional Resources
4.6
Dealing with Missing Values
4.6.1
Test for missing values
4.6.2
Recode missing values
4.6.3
Exclude missing values
5
Data Structure Basics
5.1
Structure and attributes
5.1.1
Identifying object structure
5.1.2
Understanding object attributes
5.2
Managing vectors
5.2.1
Creating vectors
5.2.2
Adding on to Vectors
5.2.3
Adding Attributes to Vectors
5.2.4
Subsetting Vectors
5.2.5
Simplifying vs. Preserving
5.2.6
Performing functions on vectors
5.3
Managing Matrices
5.3.1
Creating Matrices
5.3.2
Adding on to Matrices
5.3.3
Adding Attributes to Matrices
5.3.4
Subsetting Matrices
5.3.5
Numerical matrix operations
5.4
Managing Lists
5.4.1
Creating Lists
5.4.2
Adding on to Lists
5.4.3
Adding Attributes to Lists
5.4.4
Subsetting Lists
5.4.5
Applying functions to lists
5.5
Managing Data Frames
5.5.1
Creating Data Frames
5.5.2
Adding on to Data Frames
5.5.3
Adding Attributes to Data Frames
5.5.4
Subsetting Data Frames
5.5.5
Applying fucntions to data frames
5.6
Managing Tibbles
5.6.1
Prerequisites
5.6.2
Creating Tibbles
5.6.3
Comparing Tibbles to Data Frames
5.6.4
Printing
5.6.5
Subsetting
6
Control Statements
6.1
Conditional programming with
if
statements
6.2
Conditional programming with
if...else
statements
6.3
Looping
for
a fixed number of iterations
6.4
Looping
while
a logical statement returns FALSE
6.5
Using
repeat
loops to execute until told to break
6.6
break
/
next
to exit and skip interations
Published with bookdown
Data Science Labs’ Programming Guides
Chapter 4
Data Types
This chapter introduces the different data types.