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

## Interactive Subsetting Exercises

The function, “subset()” is intended as a convienent, interactive substitute for subsetting with brackets. subset() extracts subsets of matrices, data frames, or vectors (including lists), according to specified conditions. Answers to the exercises are available here. Exercise 1 Subset the vector, “mtcars[,1]“, for values greater than “15.0“. Exercise 2 Subset the dataframe, “mtcars” for rows […]

## Stock prices analysis part 1 exercises

In this set of exercises we are using R to analyse stock prices. This is the first part where we exercise basic descriptive statistics. You dont need to be an expert stock trader in order to understand examples. Where needed, additional explanations will be provided. All examples will be based on real historical data acquired […]

## Start here to learn R!

Ready, set, go! On R-exercises, you will find hundreds of exercises that will help you to learn R. We’ve bundled them into exercise sets, where each set covers a specific concept or function. An exercise set typically contains about 10 exercises, progressing from easy to somewhat more difficult. In order to give you a full […]

## As.Date() Exercises

The as.date() function creates objects of the class “Date“, via input of character representations of dates. Answers to the exercises are available here. Exercise 1 The format of as.Date(x, …) accepts character dates in the format, “YYYY-MM-DD”. For the first exercise, use the c() function, and as.date(), to convert “2010-05-01” and “2004-03-15” to class “date” […]

## Data Shape Transformation With Reshape()

reshape() is an R function that accesses “observations” in grouped dataset columns and “records” in dataset rows, in order to programmatically transform the dataset shape into “long” or “wide” format. Required dataframe: data1 <- data.frame(id=c("ID.1", "ID.2", "ID.3"), sample1=c(5.01, 79.40, 80.37), sample2=c(5.12, 81.42, 83.12), sample3=c(8.62, 81.29, 85.92)) Answers to the exercises are available here. Exercise 1 […]

## Summary Statistics With Aggregate()

The aggregate() function subsets dataframes, and time series data, then computes summary statistics. The structure of the aggregate() function is aggregate(x, by, FUN). Answers to the exercises are available here. Exercise 1 Aggregate the “airquality” data by “airquality$Month“, returning means on each of the numeric variables. Also, remove “NA” values. Exercise 2 Aggregate the “airquality” […]

## Scripting Loops In R

An R programmer can determine the order of processing of commands, via use of the control statements; repeat{}, while(), for(), break, and next Answers to the exercises are available here. Exercise 1 The repeat{} loop processes a block of code until the condition specified by the break statement, (that is mandatory within the repeat{} loop), […]

## zoo time series exercises

The zoo package consists of the methods for totally ordered indexed observations. It aims at performing calculations containing irregular time series of numeric vectors, matrices & factors. The zoo package interfaces to all other time series packages on CRAN. This makes it easy to pass the time series objects between zoo & other time series […]

## Lattice exercises – part 2

In this set of exercises we will use lattice package. Firstly, we have to install this package with command install.packages(“lattice”) and then we will call it library(lattice) . Lattice package permits us to create univariate, bivariate and trivariate plots. For this set of exercises we will see trivariate plots. We will use a dataset example […]