Help with codes

Hi, welcome to the forum.

It would help us to see what you have already tried. I think we need a FAQ: How to do a minimal reproducible example ( reprex ) for beginners.

In particular we likely need some sample data. A handy way to supply some sample data is the dput() function. In the case of a large dataset something like dput(head(mydata, 100)) should supply the data we need.