[R] How to de-source and re-source a file?

Duncan Murdoch murdoch.duncan at gmail.com
Tue Dec 6 19:23:01 CET 2011


On 06/12/2011 1:19 PM, Michael wrote:
> Thanks a lot!
>
> But how about removing "all the functions" in the whole "myprogram1.R"
> source file?

There's no way for R to know what you did with those functions, so no 
general way to do that.

But if you just source it again, it will overwrite the ones in the 
current evaluation frame.

Duncan Murdoch

> The reason for asking this is of course, after I made some changes, I saved
> it, and then I wanted the functions to be reloaded into memory so that I
> can do "mtrace", or "browser" etc.
>
> Thank you!
>
> 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
> >
>



More information about the R-help mailing list