[R] How to de-source and re-source a file?
Roebuck,Paul L
proebuck at mdanderson.org
Wed Dec 7 21:27:24 CET 2011
So create a checkpoint...
-----------------------------myfile.R---------------------------------
checkpoint.file <- "checkpoint_appname.RData"
if (!file.exists(checkpoint.file) {
## Do compute intensive processing...
{
my.seed <- 1234
ans <- long.comp( my.seed)
}
objects2save <- c("ans", "my.seed")
save(list=objects2save,
file=checkpoint.file)
} else {
load(checkpoint.file)
}
browser()
...
-----------------------------------------------------------------------
On 12/6/11 12:44 PM, "Michael" <comtech.usa at gmail.com> wrote:
> the problem with restarting R is that I then have to re-execute the program
> until the point where I wanted to debug, which is a very long-waiting
> time...
>
> On Tue, Dec 6, 2011 at 12:17 PM, Duncan Murdoch
> <murdoch.duncan at gmail.com>wrote:
>
>> On 06/12/2011 1:10 PM, Michael wrote:
>>
>>> i.e. how to make sure the function that was loaded into workspace/memory
>>> is
>>> the version that I edited latest... not some stale version...
>>>
>>> This might solve some of my breakpoint and browser/debug problem, even the
>>> RStudio problem that I've met....
>>>
>>
>> You can use rm() to remove a function.
>>
>> You can also quit and restart R, making sure that it *does not* load an
>> existing workspace (by deleting the .Rdata file if it exists, and never
>> answering "yes" to the question to save it.) This gives you a nice clean
>> slate.
>>
>> Duncan Murdoch
>>
>
> [[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.
More information about the R-help
mailing list