The quickest way to clear your R console

To clear the console in R, type ctrl + l on Windows or Linux, or cmd + l on Mac. This removes all the text currently visible in your console window but does not delete any variables or data stored in your environment — it only clears what you see on screen.

If keyboard shortcuts do not work in your setup, you can also type cat("\014") and press Enter. This sends a form-feed character that clears the display. Both methods do the same thing: they wipe the console clean without affecting your actual work.

Key Takeaways

  • Use ctrl + l (Windows/Linux) or cmd + l (Mac) to clear the console display instantly.
  • Clearing the console only removes what you see on screen — your variables and data remain in memory.
  • The command cat("\014") works as an alternative if keyboard shortcuts do not respond.
  • RStudio has a broom icon in the console pane that clears the display without typing anything.

Why you might want to clear your console

A cluttered console makes it harder to find the output you actually need. After running many commands, old results pile up and scroll off screen, making debugging difficult. Clearing the console gives you a fresh view without losing any of your work.

Clearing is purely visual. Your variables, data frames, and functions stay loaded in your environment. You can still access everything you created — you just cannot see the old command history on screen anymore. This is different from clearing your environment, which would actually delete your data.

Using the RStudio console broom button

If you work in RStudio, the easiest method is the broom icon in the console pane. Look for a small broom symbol in the top right corner of your console window, next to the other icons. Click it once and the console clears immediately.

This button does the same work as the keyboard shortcut but requires no typing. It is useful if you prefer clicking to keyboard commands, or if you are sharing your screen and want a visual way to show what you are doing.

The difference between clearing the console and clearing your environment

Clearing the console removes only the display — the text you see. Clearing your environment removes the actual data. If you want to delete all your variables and start fresh, use rm(list = ls()) instead. This command removes everything from memory, not just from the screen.

Many people confuse these two actions. A cleared console looks empty but your data is still there. A cleared environment means your data is gone. Know which one you need before you act, because you cannot undo clearing your environment.

Clearing the console in different R interfaces

The keyboard shortcut works in base R, RStudio, and most other R interfaces on Windows and Mac. On Linux, ctrl + l also works in most terminals running R directly. If you use a different interface or operating system, the cat("\014") command works almost everywhere.

Some older or specialized R interfaces may not respond to either method. In those cases, you can scroll up manually or close and reopen your console window. The cat() command is your most reliable fallback because it sends a standard character that nearly all terminals understand.

Clearing console history versus clearing the display

Clearing the console display does not erase your command history. You can still scroll up in the console pane to see old commands and results, or use the up arrow key to cycle through previous commands. The history stays in memory even after you clear the display.

If you want to actually delete your command history, that depends on your interface. In RStudio, you can clear history through the History pane menu. In base R, the history is stored in a file called .Rhistory in your working directory, which you can delete manually if needed.

Common mistakes when clearing the console

The most common mistake is thinking that clearing the console also clears your variables. It does not. If you clear the console and then realize you needed to see an old result, your data is still there — you just have to recreate the command or look at your variables in the Environment pane.

Another mistake is using rm(list = ls()) when you only meant to clear the display. This command deletes everything, not just the console view. If you are new to R, write this command carefully and make sure you mean it before you press Enter.

Frequently Asked Questions

Does clearing the console delete my variables?

No. Clearing the console only removes what you see on screen. All your variables, data frames, and functions remain in your environment and are still available to use. You can check what you have stored by typing ls() to list all objects in memory.

What if ctrl + l does not work on my computer?

Try cat("\014") instead. Type it exactly as shown and press Enter. This command works on Windows, Mac, and Linux in almost all R interfaces. If neither method works, you may be using a specialized interface with different controls — check your interface's documentation or menu options.

Can I undo clearing the console?

You cannot undo clearing the display itself, but your data is still there. If you need to see an old result, scroll up in the console pane or press the up arrow key to cycle through previous commands. Your command history remains available even after you clear the console.

Is there a way to clear the console automatically when R starts?

You can add cat("\014") to your .Rprofile file, which runs automatically when R starts. This clears the console each time you open R. Edit .Rprofile in your working directory or use usethis::edit_r_profile() in RStudio to open it safely.

What is the difference between clearing and scrolling?

Scrolling lets you see old output by moving up in the console pane. Clearing removes the display entirely so you start with a blank screen. Clearing is useful when you have run many commands and want a fresh view. Scrolling is better when you need to reference something you just ran.