Can you make your initial dataset reproducible?
either use dput() or reprex(). e.g. paste the output of dput(df)
dput()
reprex()
dput(df)