We will put some examples and solutions to common reasons (wrong path, attach multiple frames with same variables, etc.) here with suggestions for solutions.
The r code could not be ran because you do not have a data frame uploaded with the existing objects being called upon. Make sure to upload the data set before running this code. Next, make sure that the items are named the same as the ones we are using.
When you have two or more data sets open in R Script that share the same objects then R Script gets confused. It does not know which object and which data frame to choose from so instead it masks all the objects. You can close out everything in the R console and then open up just one data set then attach(datanamehere) or inside of function like ggplot2( data = datanamehere, ...).