my homework in R Programming