Rdata

From InterSciWiki

Jump to: navigation, search


Q: How can I save my work? 
You can save all the objects and functions that you have created in an .RData file,

by using the save or the save.image functions. It is very important that you remember to include the .RData extension when indicating the file path because R will not supply it for you!

save(file="d:/file_name.RData")
save.image("d:/file_name.RData")
Q: How can I retrieve the work that I have saved using a save.image function? 

The load function will load an .RData file.

load("d:/file_name.RData")
load("C:/Program Files/R/R-2.6.2/SCCS/sccs.RData")

R remove file unlink("bad_file")

file.remove("bad_file")


[edit] Update

Doug,

Editing the functions is extremely simple. To see a function (command) you type it's name without adding parentheses. To edit a function you type edit(function name). This opens up the local command line text editor. In my Linux version of R this defaults to vi. However it can be changed with the variable EDITOR. You can get the documentation on edit with help("edit"). Since functions are objects, as are data frames, you create a new version of a function by copying the result like this.

new_function <- edit(old_function)

The following command must be used to change a function, because edit does not alter its object.

function <- edit (function)

however there is a 'fix' command which is the equivalent of the above line

fix(function)

[edit] In reply to

On Wednesday 27 February 2008, you wrote: > I am going to try now to add some new commands to sccs.RData and also > update the .sav file. > > Could you give me a few commands that would > > extract the programs contained there.... get the > source(...) for each so I can see them, add to them, etc. > > thanks -- Doug

Personal tools