Clarification in R studio

I am a new learner of R studio, I am facing issue.. I am trying to write code in R script but it is giving error in console states object not found but the code is working fine in console giving correct output. Kindly help

It would help if you post some code and the error. A more informative title would help too.