add week3 R codes