Introduction to R
1
Welcome
2
What is R ?
3
What is RStudio ?
3.1
RStudio access
3.2
RStudio interface
3.3
Setting up the folder structure for the course
4
Paths and directories
4.1
Tree of directories
4.2
Navigate the tree of directory with the R terminal
5
R basics
5.1
Arithmetic operators
5.2
Simple calculations
5.3
Objects in R
5.4
Assignment operators
5.5
Assigning data to an object
6
Functions
7
R scripts
7.1
Create and save a script
7.2
R syntax
7.3
RStudio tips in the console
7.4
Exercice 1. Getting started.
8
Data types
9
Data structures
9.1
Vectors
9.1.1
Creating a vector
9.1.2
Vector manipulation
9.1.3
Combining vectors
9.1.4
Numeric vector manipulation
9.1.5
Character vector manipulation
9.2
Exercise 2. Numeric vector manipulation
9.2.1
Exercise 2a.
9.2.2
Exercise 2b.
9.3
Exercise 3. Character vector manipulation
9.3.1
Exercise 3a.
9.3.2
Exercise 3b.
9.4
Factors
9.5
Matrices
9.5.1
Creating a matrix
9.5.2
Two-dimensional object
9.5.3
Matrix manipulation
9.6
Data frames
9.6.1
Create a data frame
9.6.2
Data frame manipulation:
9.7
Two-dimensional structures manipulation
9.7.1
Dimensions
9.7.2
Manipulation
9.8
Exercise 4. Matrix manipulation
9.9
Exercise 5. Data frame manipulation
9.9.1
Exercise 5a
9.9.2
Exercise 5b
9.9.3
Exercise 5c
10
Missing values
11
Input / Output
11.1
On vectors
11.2
On data frames or matrices
11.3
Exercise 6.
11.3.1
Exercise 6a. Input / output
11.3.2
Exercise 6b - I/O on data frame: play with the arguments of read.table
11.3.3
Exercice 6c - I/O on a data frame
12
Library and packages
12.1
R base
12.2
R contrib
12.3
Install a package
12.4
Load a package
12.5
Check what packages are currently loaded
12.6
List functions from a package
12.7
RStudio server at CRG
12.8
Exercise 7: Library and packages
13
Regular expressions
13.1
Find simple matches with grep
13.2
Regular expressions to find more flexible patterns
13.3
Substitute or remove matching patterns with gsub
13.4
Predefined variables to use in regular expressions:
13.5
Use grep and regular expressions to retrieve columns by their names
13.6
Exercise 8: Regular expressions
14
Repetitive execution
14.1
Exercise 9: For loop
15
Conditional statement
15.1
Exercise 10: If statement
16
Basic plots in R
16.1
Scatter plots
16.2
Bar plots
16.3
Pie charts
16.4
Box plots
16.5
Histograms
17
How to save plots
17.1
With R Studio
17.2
With the console
17.3
Exercise 11: Base plots
17.3.1
Exercise 11a- scatter plot
17.3.2
Exercise 11b- bar plot + pie chart
17.3.3
Exercise 11c- histogram
18
Plots from other packages
18.1
heatmap.2 function from gplots package
18.2
venn.diagram function from VennDiagram package
19
ggplot2 package
19.1
Getting started
19.2
Scatter plot
19.3
Box plots
19.4
Dot plots
19.5
Bar plots
19.6
Histograms
19.7
About themes
19.8
Saving plots in files
19.9
Exercise 12: ggplot2
19.9.1
Exercise 12a- Scatter plot
19.9.2
Exercise 12b- Box plot
19.9.3
Exercise 12c- Bar plot
19.9.4
Exercise 12d- Histogram
19.10
More about the theme() function
19.11
Volcano plots
20
Introduction to Exploratory Data Analysis & Descriptive Statistics."
20.1
Exploratory Data Analysis
20.1.1
Data dimentionality: functions
str(), summary(), head(), tail()
20.1.2
Missing (NA) values in data: functions
complete.cases(), na.omit(), all.equal()
20.1.3
Looking at the subset of data
20.1.4
Excercises on data subsetting and missing values
20.1.5
Exploring a particular variable (column): functions
unique(), table()
20.1.6
Exploring relationships between variables: functions
table(), cut()
, and functions for factors
levels(), nlevels()
20.1.7
Excercises using
unique(), table()
and
cut()
20.2
Descriptive Statistics
20.2.1
Functions:
mean, sd, var, min, max, median, range, IQR, quantile
.
20.2.2
Functions
tapply() and round()
20.2.3
Excercises
20.2.4
Data visualization:
boxplot()
20.2.5
Outliers
20.2.6
How statistics change if to remove outliers
20.3
More basic plots
20.3.1
How to plot box-plots side-by-side on one graph
20.3.2
Excercise: Make a similar boxplot using
ggplot()
20.3.3
How to plot together data from two or more vectors of different lengths
20.3.4
How to make a box-plot more informative and customized
20.3.5
Histogram
20.3.6
Control for the size of bins
20.3.7
Two overlaying histograms on one graph
20.3.8
Scatterplot
20.3.9
Function
palette()
20.4
Wrapping up everything you have learned in this course
20.4.1
Read data from the file
20.4.2
Remove empty columns
20.4.3
Explore, rename and clean variables
20.4.4
Correct non-numeric values, changing them to NA
20.4.5
Write corrected data frame in the file
20.4.6
Explore and remove outliers
20.4.7
How to change a value of a specific data point
20.4.8
Make a data frame with statistical data
20.4.9
Format a data frame
20.4.10
Write a data frame in the file
20.4.11
Write a table using as a decimal separator instead of a dot a comma
Published with bookdown
Introduction to R
Part13
Regular expressions
Regular expressions are tools to
describe patterns in strings
.