Introduction to RStudio


Data Types and Structures


Analysing Patient Data


Figure 1

Variables as Tags

Figure 2

Variables as Tags

Figure 3

Reassigning Variables

Figure 4

Creating Another Variable

Figure 5

Updating a Variable

Figure 6

Assigning Variables

Figure 7

Assigning Variables

Figure 8

Operations Across Margins

Figure 9

Scatter plot of average inflammation versus time demonstrating the result of using the plot function
Scatter plot of average inflammation versus time demonstrating the result of using the plot function

Figure 10

Scatter plot of maximum inflammation versus time demonstrating the result of using the plot function
Scatter plot of maximum inflammation versus time demonstrating the result of using the plot function

Figure 11

Scatter plot of minimum inflammation versus time demonstrating the result of using the plot function
Scatter plot of minimum inflammation versus time demonstrating the result of using the plot function

Addressing Data


Figure 1


Figure 2

2. In addition to dat$Group != 'Control', one could use dat$Group %in% c("Treatment1", "Treatment2").


Reading and Writing CSV Files


Figure 1

csv written without row.names argument

Figure 2

csv written with row.names argument

Figure 3

csv written with -9999 as NA

Understanding Factors


Figure 1

Bar chart showing control and treatment to emphasise how the function table() tabulates observations.

Figure 2

Bar chart showing control and treatment to emphasise how the function factor() moves the control group to the last coulumn.

Figure 3

Bar chart showing gender values in the dataset have been coded incorrectly.

Figure 4

Barplot graph showing blood pressure in males and females.

Figure 5


Figure 6


Creating Functions


Making Choices


Figure 1

Executing a Conditional

Figure 2


Figure 3


Figure 4

A grey unlabeled boxplot chart showing the distrubution values between 2 and 9 with a mean at 6.

Figure 5

A grey unlabeled histogram showing bimodal distribution between 2 and 9 with peaks at 2 and 6.

Figure 6

A mostly blank strip chart showing five points at 3, 4, 6, 7, and 9

Figure 7


Analysing Multiple Data Sets


Figure 1

Scatterplot of average daily inflammation over 40 days, increasing in a mostly straight line until day 20, and then decreasing in a mostly straight line to visualise inflammation levels in a single dataset.A scatterplot of maximum daily inflammation over 40 days, increasing in a straight line until day 20, and then decreasing in a straight line to visualise inflammation levels in a single dataset.A scatterplot of minimum daily inflammation over 40 days, increasing in a step-wise pattern until day 20, and then decreasing in a step-wise pattern to visualise inflammation levels in a single dataset.


Figure 2

A scatterplot of average daily inflammation over 40 days, increasing in a mostly straight line until day 20, and then decreasing in a mostly straight line to visualise inflammation levels in a single dataset.A scatterplot of average daily inflammation over 40 days, increasing in a mostly straight line until day 20, and then decreasing in a mostly straight line to visualise inflammation levels in a single dataset.A scatterplot of average daily inflammation over 40 days, increasing in a mostly straight line until day 20, and then decreasing in a mostly straight line to visualise inflammation levels in a single dataset.


Figure 3

Scatterplot of average daily inflammation showing a ramp with a peak at 20 days.Scatterplot of average daily inflammation showing a ramp with a peak at 20 days.Scatterplot of average daily inflammation showing a ramp with a peak at 20 days.


Figure 4

Scatterplot of average daily inflammation showing a ramp with a peak at 20 days.Scatterplot of average daily inflammation showing a ramp with a peak at 20 days.Scatterplot of average daily inflammation showing a ramp with a peak at 20 days.


Figure 5

Scatterplot of average daily inflammation showing a ramp with a peak at 20 days.Scatterplot of average daily inflammation showing a ramp with a peak at 20 days.Scatterplot of average daily inflammation showing a ramp with a peak at 20 days.


Loops in R


Best Practices for Writing R Code