How to clear R command history in RStudio?

I want to completely clear my R command history in RStudio. I'm talking about when I press the up and down arrow keys, not just clearing the console by clicking the broom.

I tried deleting the .Rhistory file in my working directory and restarting RStudio but the file keeps restoring itself. How do I completely get rid of it?

1

1 Answer

To clear the workspace environment use:

rm(list = ls())

To clear history of commands typed use:

clearhistory <- function() { write("", file=".blank") loadhistory(".blank") unlink(".blank")
}
clearhistory()

Reference:
This discussion might be helpful: Command or keyboard shortcut to clear command history in RStudio

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like