I want to save an image of the workspace in the .RData file but without exiting the current session. Something like q('yes')
but without quitting.
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 ).
For this, click the File menu and then click save workspace. You will see the dialog box, browse to the folder where you want to save the file and provide the file name of your own choice. Question: How one can access the saved work, while work is saved using save.
You should almost never answer yes. 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.
You can use save.image()
at any time to save all environment data into an .RData
file:
save.image(file='yoursession.RData')
To load this data later you can use:
load('yoursession.RData')
Apart from save.image()
function, that lets you save the entire workspace, you can also check the save()
function.
save()
function lets you save individual objects in the workspace.
save(ObjectToBeSaved, file = "FileName.RData")
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