This question seems to be about using the R language, not specifically about using R Markdown (a system for mixing code with text to produce reports in different formats), so I am changing the category to #general.
Also, for the benefit of future readers… Before posting classwork/homework questions here, please read our Homework Policy. The key bits:
- Clearly state that your post is class-related
- Don't post verbatim text from assignments or problem sets
- Show the work you've already done and don't expect anyone to solve the whole problem for you