R Studio can't find y

It would be better if you showed exactly the code you used and the results to be sure everyone is on the same page. Perhaps use reprex, as in FAQ: What's a reproducible example (`reprex`) and how do I create one?