To be able to provide any useful guidance to your problem, it is necessary to have the data that you are starting from (or at least a glimpse of it) - a so-called reproducible example (or "reprex" for short). Could you please provide that? Using dput is useful for providing an example of your data for other users to use.