Solutions to chapter 6: R exercises 8 and 9

Change-Id: I112c7d6032d872ac0d01ab93c3632f8ddb8b51e2
Merge pull request #24 from sjuvekar/master

Solutions to chapter 6: R exercises 8 and 9