Error: mydata not found

Hi all,
I am trying to create a plot in Rshiny with a vertical bar that changes location depending on the input data. It runs fine in my console, but once I clear the environment and RunApp() , it says 'mydata not found', and the plot is not shown.
However, I defined mydata prior to the ui() and server() functions. Moreover, I have defined it within the server function. Somehow it is not recognized. Can anyone please advice?
Many thanks,