When I exit the interactive R shell, it displays an annoying prompt every time:
> > Save workspace image? [y/n/c]: n
I'm always answering "no" to it, because if I wished to save my work, I'd do that before trying to exit.
How to get rid of the prompt?
Note: see ?save.image
Saving your workspace creates an image of your current variables and functions, and saves them to a file called ”. RData”. When you re-open R from that working directory, the workspace will be loaded, and all these things will be available to you again. But you don't want that, so don't save your workspace.
The workspace is your current R working environment and includes any user-defined objects (vectors, matrices, data frames, lists, functions). At the end of an R session, the user can save an image of the current workspace that is automatically reloaded the next time R is started.
Saving the workspace in R is very easy. In case you want to save the full workspace in R, also known as workspace image (those objects that are displayed when you call the ls function), you can use the save. image function. The data will be saved in a file of type RData (also known as rda ).
You can pass the --no-save
command line argument when you start R, or you can override the q
function:
utils::assignInNamespace( "q", function(save = "no", status = 0, runLast = TRUE) { .Internal(quit(save, status, runLast)) }, "base" )
Put the above code in your .Rprofile so it will be run on startup for every session.
Haven't found the easiest Linux solution yet :)
On ubuntu add the following line to your ~/.bashrc
:
alias R='R --no-save'
Every time you start the R console with R
, it will be passed the --no-save
option.
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