20) Saving .Rdata to file.

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

Machine learning is predominately a challenge of data abstraction – this is the shaping and molding of data – and presenting it to advanced machine learning algorithms on a commodity basis.  It follows that upon having spent time and effort creating an elaborate Data Frame,  it likely that it will need to be saved for future use (if only to avoid the computational expense of recreating it).

The save() function exists for the purpose of saving most objects that can be created and populated with data to a file in the working directory.  It is a very important part to deploying models on a real-time basis.

To save the Data Frame LabeledDataFrame and BucketList to a specified file by the name of "Example.RData":

save(LabeledDataFrame,BucketList,file = "Example.RData")
saving-an-object-script-in-r.png

Run the line of script to console:

saved-object-written-to-r-console.png

A file titled Example.RData is not written out to the Working Directory.  To remind the working directory:

getwd()
check-working-directory-script-in-r-for-save-validation.png

Run the line of script to console:

working-directory-written-out-to-r-console-for-save-validation.png

Having identified the working directory, navigate to the same in windows explorer:

object-saved-in-file-system-by-r.png

The saved file is clearly visible in this directory ready for real-time deployment or being reloaded to an R session.