Problem 1 (R): solved