chapter 8 r code for a few problems (incomplete)