Your problem description is pretty confusing to me and I'm not entirely sure what it is you like to do (i.e. what the output should look like).
Can you generate a reprex of the problem and also provide an actual example of what the input / output should look like. A reprex consists of the minimal code and data needed to recreate the issue/question you're having. You can find instructions how to build and share one here: