It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions.
– MrFlickJul 24 '20 at 00:37
@DanielaDiaz Please tell us what you have tried then. And provide a runnable code snippet and a proper data sample.
– vestlandJul 27 '20 at 13:15