R’s boxplot function has a lot of useful parameters allowing us to change the behaviour and appearance of the boxplot graphs. In this exercise we will try to use those parameters in order to replicate the visual style of Matlab’s boxplot. Before trying out this exercise please make sure that you are familiar with the […]

# Exercises

## Advanced Base Graphics Exercises

Being able to visualize information through plots is essential for a statistic analysis. A simple and clean graph can explain much more than words. In this set of exercises you will test and learn advanced graphic arguments. Before you start check the documentation for the following functions: plot, points, abline, title, legend ,par (including all the arguments), mfrow and layout For […]

## Paired t-test in R Exercises

The paired samples t test is used to check if there are any differences in the mean of the same sample at two different time points. For example a medical researcher collects data on the same patients before and after a therapy. A paired t test will show if the therapy improves patient outcomes. There […]

## Applying Functions To Lists Exercises

The lapply() function applies a function to individual values of a list, and is a faster alternative to writing loops. Structure of the lapply() function: lapply(LIST, FUNCTION, …) The list variable used for these exercises: list1 <- list(observationA = c(1:5, 7:3), observationB=matrix(1:6, nrow=2)) Answers to the exercises are available here. Exercise 1 Using lapply(), find […]

## Network Analysis Part 1 Exercises

In this set of exercises we shall create an empty graph and practice the functions for basic manipulation with vertices and edges, using the package igraph. If you don’t have the package already installed, install it using the following code: install.packages(“igraph”) and load it into the session using the following code: library(“igraph”) before proceeding. You […]

## Independent t test in R

The independent t test is used to test if there is any statistically significant difference between two means. Use of an independent t test requires several assumptions to be satisfied. The assumptions are listed below The variables are continuous and independent The variables are normally distributed The variances in each group are equal When these […]

## Efficient Processing With Apply() Exercises

The apply() function is an alternative to writing loops, via applying a function to columns, rows, or individual values of an array or matrix. The structure of the apply() function is: apply(X, MARGIN, FUN, …) The matrix variable used for the exercises is: dataset1 <- cbind(observationA = 16:8, observationB = c(20:19, 6:12)) Answers to the […]

## Examining Data Exercises

One of the first steps of data analysis is the descriptive analysis; this helps to understand how the data is distributed and provides important information for further steps. This set of exercises will include functions useful for one variable descriptive analysis, including graphs. Before proceeding, it might be helpful to look over the help pages […]

## Fundamental and Technical Analysis of Shares Exercises

In this set of exercises we shall explore possibilities for fundamental and technical analysis of stocks offered by the quantmod package. If you don’t have the package already installed, install it using the following code: install.packages(“quantmod”) and load it into the session using the following code: library(“quantmod”) before proceeding. Answers to the exercises are available […]

## Dates and Times – Simple and Easy with lubridate exercises (part 2)

This is the second part in the series teaching the “lubridate” package. As a short recap from the previous part, I mentioned that date/date_time formats are easily parced using the ymd set of functions (for example, dmy, ymd_h, etc). I also explained that arithmetic calculations are performed using the days, months, years, etc. functions. In […]