R markdown creates an empty data frame while executed code chunks do not


Welcome to the RStudio community!

This is indeed peculiar behaviour, but difficult to evaluate the source of the problem without being able to run the code myself. Could you try and generate a reprex? 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:

Good luck,