added R solution to problem 4