Can someone check my assignment please?

Hi, and welcome!

A couple of preliminaries. Please see the homework policy and use reproducible examples, reprex .

A reprex almost always needs to include a dataset that will work with the code. It doesn't have to be the full dataset, just an extract or, ideally, a standard data() object that is similar or you can adjust to make similar. mtcars is popular for that purpose.

For your problem, there are two tools that may prove helpful: