[R] how to save the R script itself into a rData file?
jim holtman
jholtman at gmail.com
Sun Jan 22 02:14:48 CET 2012
Create a function that you can pass the name of the R script to run
and the fileName you want applied to the output files. First copy the
R script to a file with the 'fileName.R' that as passed in, then
'source' the file to execute it. Change your script to also use the
'fileName' to create the RData file. That will create two files
(source and data) that should allow you to recreate your data.
On Sat, Jan 21, 2012 at 7:24 PM, Michael <comtech.usa at gmail.com> wrote:
> Hi all,
>
> As a part of work flow, I do a lot of experiments and save all my results
> into rData file...
>
> i.e. at the end of all my experiments, I do
> "save.image("experiment_name_with_series_number.rData")"...
>
> However, some times even with the rData files, I cannot remember the
> context where these data files were generated.
>
> Of course, I can make the R data file names and the R script file names the
> same, so that whenever I see a data file, I will be able to track down to
> how the result file was generated.
>
> This is fine. But sometimes a bunch of different results rData files were
> generated simply from varying a parameter in the same R script file.
>
> It's kind of messy to save different R script files with different names
> when only parameters are different, and not to say if there are a bunch of
> parameters that need to be put into file names...
>
> Lets say I changed the parameters x to 0.123, y to -0.456, z to -999.99
>
> Then I have to save the R script file as
> "Experiment_001_x=0.123_y=-0.456_z=-999.99.r"
>
> and the result file as "Experiment_001_x=0.123_y=-0.456_z=-999.99.rData"
>
> ...
>
> This is kind of messy, isn't it?
>
> Is there a way to save the whole script file (i.e. the context where the
> data file is generated) into the rData file? It cannot be the file location
> and/or file name of the R script file; it needs to be the whole content of
> the file... to prevent the parameters change .. i.e. the same R script file
> but with different combinations of parameters...
>
> How to do that?
>
> Any good tricks?
>
> Thanks a lot!
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
--
Jim Holtman
Data Munger Guru
What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.
More information about the R-help
mailing list