How to "erase" a wrong code

Hi, I'm fairly new to R, so any help would be appreciated. So if I define a variable, but found there's a mistake in the code, if I type the correct code, since it is new, will then take the place of the older code.
But if I am in the middle of entering in a function, and then I found a mistake, do I need to start typing in the whole function again? What are some options I can choose from? There has to be another way to do it other than restarting the whole script.
Anther question I have is, why does all the objects from a previous session be in the environment every time I open a new Rstudio session, when I've done the rm function ? How do I permanently erase the old objects from the environment?

Thank you!

Hi @Altec, it sounds like you may writing your code in the console, rather than in an R file: If you use File > New File > RScript, you'll see a new R file open in the upper left pane, and you can enter and edit your function there. It's an extra step to execute your code from your R file, either by highlighting it and pressing 'Run', or using keyboard shortcuts to do it.

And in terms of removing old objects, you can use Tools > Global Options... and have your selections look like this:

1 Like

Thank you so much! I was able to get my problems resolved!

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.