From b.rowlingson at lancaster.ac.uk  Wed Feb 10 16:06:26 2010
From: b.rowlingson at lancaster.ac.uk (Barry Rowlingson)
Date: Wed, 10 Feb 2010 15:06:26 +0000
Subject: [Rd] R Startup configuration file
In-Reply-To: <4B729C0F.3030301@stats.uwo.ca>
References: <d8ad40b51002100123s4b1d77bmc27ece9686106ef@mail.gmail.com>
	<4B729C0F.3030301@stats.uwo.ca>
Message-ID: <d8ad40b51002100706t5869535av162a43a6362d6c6b@mail.gmail.com>

On Wed, Feb 10, 2010 at 11:44 AM, Duncan Murdoch <murdoch at stats.uwo.ca> wrote:

> When I read the ?Startup man page, I find it is too complicated already; I
> don't want to add another kind of file to read. ?(Would we have ?separate
> user and site versions of this new file? ?When would it be handled?)
>
> However, we could achieve what you are asking for with no changes to base R.
> ?One way would be to write a small package to handle options. ?When you want
> to save a setting, you call a function there that writes it to a private
> file. ?Then you manually add a line to your .Rprofile, saying something like
> "myOptionPackage::loadMyOptions()". ?This can do whatever you want, it only
> needs to know how to parse the file that your package wrote.
>

 Yup, I'd already thought about this. However it does mean that any
other packages or applications that use this feature are going to have
to say "make sure you have saveableOptions::loadMyOptions() in your R
profile startup somewhere". Resulting in "huh what?" from users.

 Actually that's not true if the options are only used in add-on
packages - they can require(saveableIOptions) and load them in their
package .First.lib or .onLoad code. It's only options in the R base
(set by options()) that you need to hack code in order to run at
startup...

 In most modern programs, options and setup state are stored when the
user hits the 'apply' button. Even emacs can handle customisation in a
set of config files these days. Can't remember the last time I hacked
lisp in my .emacs file.

 But I agree that writing a saveable options package is the first step
- then making that a default in R is the second so people don't have
to edit profiles and R packages and applications can expect an API for
savable state.

 As for Startup Overload Syndrome - yes, ?Startup is a bit complicated
already. Maybe a sign it needs simplifying!

Barry



[Rd] R Startup configuration file
Barry Rowlingson