Welcome to R !
Have you tried anything ? Have you any error or question ?
For now it looks like you are asking to solve an exercice for you.
If you need ressource for beginners, we'll be happy to provide some.
(Just in case, FAQ: Homework Policy)