[Rd] R Startup configuration file

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Wed Feb 10 10:23:33 CET 2010


Currently when R starts up it can be configured by a file of
environment variable specifications and a file of R code. This makes
programmatic modification of startup configuration tricky.

Case in point: I start R, do install.packages("foo"), and up pops the
'choose a CRAN mirror' dialog. I'd like to put a 'Save my choice'
button on that dialog. Currently it would have to put
'options(repos="http://example.com/cran")' into my .Rprofile file. Of
course my .Rprofile file could be full of all sorts of other code, so
there's no easy way to do this and guarantee it will work.

Could we have a ".Rconfig" file, consisting of key-value pairs in a
standard config file form (or XML?), that is read at startup and
applies the key-value pairs to options(key=value)? Obviously more
detail is needed, such as whether to just have one .Rconfig file in
the users' $HOME or in individual folders, where to put a system
Rconfig file, whether it is applied before or after .Rprofile etc.

Or is it a dumb idea? I can see other ways of doing this, such as
saving the options() as an object and re-loading it at startup, but a
config file has the advantage of being simply read-writable by humans
and computers.

I notice several other package using options-style things that might
benefit from a simple persistence framework. For example the sm
package says in ?sm.options:

     This offers the possibility of customizing the functioning of the
     'sm' library, for instance by insertions of appropriate calls to
     'sm.options' in a load hook for package 'sm'.

To which the average user goes 'huh what?'. With a config file there
could be a save.sm.options() function that wrote a new section to the
user's .RConfig:

[sm]
 whatever = 99
 doSomething = TRUE

which the sm package would read in when it is first attached.

My usual R-devel caveats - yes, I know everyone has day jobs; yes, I'm
sure there are problems with it; no, I don't expect it to get done
unless someone thinks it's a Good Thing because I probably don't have
time for it; yes, R is wonderful and fantastic and you devs do a
fantastic job.

Barry

-- 
blog: http://geospaced.blogspot.com/
web: http://www.maths.lancs.ac.uk/~rowlings
web: http://www.rowlingson.com/
twitter: http://twitter.com/geospacedman
pics: http://www.flickr.com/photos/spacedman



More information about the R-devel mailing list