logo

Remove All Variables and Clear Console in R 📂R

Remove All Variables and Clear Console in R

Overview

R is an interpreted language, so you end up working continuously looking at the console. In this process, for debugging or other purposes, various tests must be done in the same working environment. There can be instances where a certain variable created during testing is very important but the programmer fails to recognize it and it does not get included in the final version. Situations like, “It definitely worked at home yesterday, but suddenly it doesn’t work at today’s presentation,” are mostly due to such issues.

Tips

The ls() function returns a list of the variable names that have been created so far as strings.

20171111\_150649.png

After taking these as a list, running the rm() function will remove all the variables.

20171111\_151604.png

After deletion, checking with ls(), you can verify that it returns no strings.

20171111\_150701.png

If you are using R studio, instead of using the command mentioned above, you can reset your workspace with a simple click. Additionally, separate from removing variables, you can clean up the console window neatly through Ctrl + L. It’s important to remember that a tidy environment leads to fewer mistakes.

In other languages