added exercise 4 for R programming