[R] .Rprofile vs. First (more of an opinion question)

Jim Lemon drjimlemon at gmail.com
Wed Mar 11 09:37:10 CET 2015


Hi Erin,
If you want to use .First, just put it in the directory where you start up
your R session, use it to change all the options that you want for all
projects, then source a file to switch to the directory that you want. I
call mine "SelectAnalysis.R" and it just displays a list of current
projects from which I select one with a letter key.

Jim


On Wed, Mar 11, 2015 at 11:51 AM, Jeff Newmiller <jdnewmil at dcn.davis.ca.us>
wrote:

> I concur with Rolf.
>
> .RData files (the ones with nothing before the period) are just traps for
> your future self, with no documentation. I avoid them like the plague. I
> refer to specifically-named Something.RData files in my .R/.Rnw/.Rmd files
> to cache results of long computations, but they are optional in my workflow
> because I always have R code that can regenerate them.
>
> .Rprofile files offer consistency of behavior  regardless of which working
> directory you use, and you can comment them.
> ---------------------------------------------------------------------------
> Jeff Newmiller                        The     .....       .....  Go Live...
> DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live
> Go...
>                                       Live:   OO#.. Dead: OO#..  Playing
> Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
> /Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
> ---------------------------------------------------------------------------
> Sent from my phone. Please excuse my brevity.
>
> On March 10, 2015 3:38:20 PM PDT, Rolf Turner <r.turner at auckland.ac.nz>
> wrote:
> >On 11/03/15 11:17, Erin Hodgess wrote:
> >> Hello again
> >>
> >> I am using R-3.1.2 on Windows 7.
> >>
> >> I am the only one using this particular computer.
> >>
> >> My question is probably more of an opinion question.
> >>
> >> I want to set a "repos" with the options.  Also, I want to setwd and
> >load a
> >> particular workspace.
> >>
> >> Am I better off to put everything into .Rprofile, please?  Or .First?
> >>
> >> Or put the options into .Rprofile and everything else into .First,
> >please?
> >>
> >> Thanks for any help.
> >
> >How do you create your .First() function and get it into your
> >workspace?
> >
> >I may be confused here, but I think that you would need to make sure
> >that this is done in each workspace (in each working directory) that
> >you
> >use.  It may be the case that you use only a single working directory,
> >but it is generally good practice to use a different working directory
> >for each separate project that you engage in.
> >
> >In contrast, putting your settings in .Rprofile causes them to be
> >applied in any working directory in which you start R.
> >
> >I also think that there's more danger of .RData getting lost or
> >over-written --- it is getting used all the time, whereas .Rprofile
> >just
> >sits there and does its thing once it's been created --- than there is
> >of .Rprofile getting lost or over-written.
> >
> >Consequently my 2 bob's worth is:  Use .Rprofile.
> >
> >Of course, this is a case of the blind leading the blind.  Caveat
> >lector.
> >
> >cheers,
> >
> >Rolf
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list