Program 2 for R