Is there a reason why an R code would run in console but not in script?

I am working on a case study and I am pretty new to the r space and I was working this on R markdown to keep track of everything. The code in the script worked yesterday before I restarted my computer and today it is giving me trouble so I tried running the code in the console. The code works in the console but it does not work in the script. Why is that?

I legit copied and pasted the same code from the script into the console and it ran through the console.