21) Loading .Rdata from file.

This Blog entry is from the Data Structures section in Learn R.

To fully demonstrate the process of loading objects from an RData file fully close down RStudio by clicking File,  then upon the menu expanding,  clicking Quit Session or by clicking on the close button in the top right hand corner:

means-to-save-an-rstudio-workspace.png

As expected from other procedures confirmation will be sought about the treatment of the current session.  Elect not to save the session by clicking "Don’t Save":

confirmation-not-to-save-r-workspace.png

Upon termination of RStudio,  simply reload:

no-workspace-when-r-studio-is-loaded.png

It can be seen that there are no objects loaded.  Assuming the working directory is unchanged, to load the objects saved in procedure 38, simply type:

load("Example.RData")
a-script-to-load-an-object-that-has-previously-been-saved-in-r.png

Run the line of script to console:

r-console-showing-the-object-to-have-been-loaded-without-error.png

The objects saved previously are promptly loaded and available in the environment pane of RStudio and by implication available for recall in scripts and \ or the console.

after-load-the-object-is-available-in-rstudio-environment-window.png

As R has several programmatic implementations,  such as R.net which is used for real-time invocation,  the saving and loading of R sessions provides a useful means to be able to deploy objects.