See the FAQ: How to do a minimal reproducible example reprex for beginners. This is almost it, aside from
pivot is missing. A reprex gives you a chance to catch that before posting.
A couple of minor things:
is considered bad form, because someone running the reprex may have other objects in memory that they care, perhaps, deeply about.
also is bad form because it messes with the user's setup, which may be non-standard. Instead use
require(purrr)
Without pivot I can't test, but what you probably need to do is to "catch" the return value of the for loop. That's as simple as
my_result <- for(i in seq_along(source_object) my_code