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 […]

## Reshape 2 Exercises

The Reshape 2 package is based on differentiating between identification variables, and measurement variables. The functions of the Reshape 2 package then “melt” datasets from wide to long format, and “cast” datasets from long to wide format. Required package: library(reshape2) Answers to the exercises are available here. Exercise 1 Set a variable called “moltenMtcars“, by […]

## Using MANOVA to Analyse a Banking Crisis Exercises

In this set of exercises we will practice multivariate analysis of variance – MANOVA. We shall try to find if there is a difference in the combination of export and bank reserves, depending on the status of banking sector (is there a crisis or not). The data set is fictitious and servers for education purposes […]

## Matrix Operations Exercises

This set of exercises will help you to learn and test your skill in matrix operations, starting with basic ones like scalar multiplication all the way through eigenvalue and eigenvectors. Before proceeding, it might be helpful to look over the help pages for the diag, t, eigen, and crossprod functions. If you want further documentation […]

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

As in any programming language, handling date and time variables can be quite frustrating, since, for example, there is no one single format for dates, there are different time zones and there are issues such as daylight saving time. Base R provides several packages for handling date and time variables, but they require mastering cumbersome […]

## Combinations Exercises

When doing data analysis it happens often that we have a set of values and want to obtain various possible combinations of them. For example, taking 5 random samples from a dataset of 20. How many possible 5-sample sets are there and how to obtain all of them? R has a bunch of functions that […]

## Stock Prices Analysis part 3 – Exercises

This is the third and the final part of the exercises dedicated to analysis of stock prices. In this part we will provide exercises for testing the type of distribution of stock prices and analysing and predicting stock prices using ARIMA models. You dont need to be an expert stock’s trader in order to understand […]

## Higher Order Functions Exercises

Higher order functions are functions that take other functions as arguments or return functions as their result. In this set of exercises we will focus on the former. R has a set of built-in higher order functions: Map, Reduce, Filter, Find, Position, Negate. They enable us to complete complex operations by using simple single-purpose functions […]

## Stock prices analysis part 2 exercises

This is the second part of the exercises dedicated to analysis of stock prices. In this part we will provide exercises for plotting, fitting linear model and predicting stock prices. You dont need to be an expert stock’s trader in order to understand the examples, but you should go through part 1, since we shall […]