Thanks, Danut: It's a little difficult to tell whether we're on the same page, so could you do the following?
- Copy and paste the all of content from the first block from the code I posted (and only the first block).
- Select all of that content (and only that content) and run
reprex()on it. (If you're not familiar withreprex, see this post.) - Past the
reprex()output here, as is.
That should help us see where to go next.