Is the dataset available and loaded in the previous chunks ? When you run chunk by chunk you need to be sure that data are available.
Currently, we don't have a reprex to reproduce so it so we can't really help further
(FAQ: What's a reproducible example (`reprex`) and how do I create one?)