In R, how to remove all of the typed commands from the command window, so that I can have a clearer working environment.
A common way to do that is to use the `clear` command, or its keyboard shortcut CTRL+L.
To clear all variables from the current workspace, use clear or clearvars . To clear all global variables, use clear global or clearvars –global . To clear a particular class, use clear myClass .
clc clears all the text from the Command Window, resulting in a clear screen. After running clc , you cannot use the scroll bar in the Command Window to see previously displayed text. You can, however, use the up-arrow key ↑ in the Command Window to recall statements from the command history.
Clear Terminal via Ctrl+L / Ctrl+Shift+K Shortcut Keyboard shortcuts also work for clearing the terminal, depending on the terminal emulator. An alternative in some terminal emulators is Ctrl + Shift + K .
On windows using RGui, a mac inside the terminal, or on Linux: Ctrl+L will clear the screen for you. You won't be able to scroll up to view what you've done in the session previously though. You can still use the up arrow to scroll through your history though.
On a mac using the gui: Option+Command+L will do the same thing as clearing in the windows gui.
On any system: You could create a function to do something similar to clearing the screen for you:
clr <- function(){cat(rep("\n", 50))}
All this does is prints enough linebreaks to essentially push everything above what is viewable on the console. You can still scroll up to view the previous output but you'll have 50 lines of whitespace. Depending on your monitor size you might need to increase the number of line breaks to clear everything.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With