It sounds like this might be a homework question. If it is, please see our homework policy.
If you've written some code and are having a particular problem, please add a minimal reprex (reproducible example) to your post. This will ensure we're all looking at the same data and code. A guide for creating a reprex can be found here.