[R] Saving/loading custom R scripts

Joshua Wiley jwiley.psych at gmail.com
Thu Sep 9 18:41:24 CEST 2010


On Thu, Sep 9, 2010 at 9:28 AM, Jakson A. Aquino <jaksonaquino at gmail.com> wrote:
> On Thu, Sep 9, 2010 at 1:14 PM, Joshua Wiley <jwiley.psych at gmail.com> wrote:
>> On Thu, Sep 9, 2010 at 7:05 AM, Bos, Roger <roger.bos at rothschild.com> wrote:
>>> Josh,
>>>
>>> I liked your idea of setting the repo in the .Rprofile file, so I tried it:
>>>
>>> r <- getOption("repos")
>>> r["CRAN"] <- "http://cran.stat.ucla.edu"
>>> options(repos = r)
>>> rm(r)
>
> I couldn't understand why to use 4 lines of code... You could try this:

You can have more than one repository, using repos = "url", will
overwrite all of them.  For instance, I believe it is standard on
Windows to have CRAN and CRANextra.  The one line option probably
would be fine often.  In any case, reading through the documentation,
the code used there is:

local({r <-
          getOption("repos"); r["CRAN"] <- "http://my.local.cran";
          options(repos=r)})

perhaps wrapping it in local() will take care of your problem, Roger.

>
> options(repos = "http://cran.stat.ucla.edu")
>



More information about the R-help mailing list