Reference the dataframe that is drawn from the for loop

Hi @vinayprakash808!

It's definitely helpful to cut your code down to only the parts that relate to your question, but it's also possible to go too far, which is what I'm afraid has happened here. In order for people to be able to help, the code still needs to be complete enough to run on someone else's computer.

I can't say much about what's causing your problem, because I have no idea where the two lines in your Step 2 code occur relative to each other, and to other code in the surrounding app. For instance, I can't see where in your app p1 gets created, so I can't even begin to suggest why you might be having trouble with it. And I can't see exactly what error is occurring, so I also don't quite know what "not able to reference p1" means in this case (there are lots of different ways you can get the same error symptoms).

But as I think you've figured out, the best way to help people here understand what's going wrong is not to provide all the code for the app :sweat_smile:. What you need to do is make a new, bare bones shiny app that has just enough code in it to demonstrate your problem in a way that is faithful to your real app. This can be a difficult task when you're not used to doing it, and it may require some thought and some trial and error.

For a bare bones Shiny skeleton app that you can use as a starting point for composing a reproducible example, see this FAQ: Shiny debugging and reprex guide. Another approach is to start with a copy of your app, then delete everything that's not related to your problem — but make sure to leave enough of the Shiny skeleton so that the app is actually an app!