You will find the solutions to the exercises below.

Chapter 1 – Setting GNU R for Predictive Modeling

Chapter 1 already contains the exercises and solutions.

Chapter 2 – Visualizing and Manipulating Data Using R

One way to solve this is to first create a vector with a size of 1001 (line 1). The first value is the money that the player comes with (assigned on line 2). On line 3, we assign a copy of the isRed attribute to the wins vector. On lines 5 to 7, we compute the amount of money at each trial by adding 1 to the money on the next turn if the drawn number is red, and remove 1 if the number is not red. On line 8, we set the graphic parameters to contain a single plot (using argument mfrow) and to be of the required dimensions (10 by 4 ...

Get R: Predictive Analysis now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.