From ggrothendieck at gmail.com  Mon Nov 22 17:34:59 2010
From: ggrothendieck at gmail.com (Gabor Grothendieck)
Date: Mon, 22 Nov 2010 11:34:59 -0500
Subject: [Rd] how to store package options over sessions?
In-Reply-To: <1CD42D9B-8CD0-42E8-96DE-9F46327E8E60@gmx.de>
References: <1CD42D9B-8CD0-42E8-96DE-9F46327E8E60@gmx.de>
Message-ID: <AANLkTimxq=FRZb29kQVdo8hqzO7LvnCJEJWEviC16-0B@mail.gmail.com>

On Sat, Nov 20, 2010 at 11:12 AM, Mark Heckmann <mark.heckmann at gmx.de> wrote:
> Hi,
> I posted this a week ago on r-help but did not get an answer. So I hope that someone here can help me:
> I want to define some options for my package the user may change.
> It would be convenient if the changes could be saved when terminating
> an R session and recovered automatically on the next package load.
>
> Is that possible and if yes, is the standard way to implement this?
>

You can use options and getOptions for this.  The user can place an
options command in their .Rprofile or just enter it into their session
to override the defaults.  See ?options .  For example, in the gsubfn
package look at the engine argument:

> library(gsubfn)
Loading required package: proto
> args(gsubfn)
function (pattern, replacement, x, backref, USE.NAMES = FALSE,
    ignore.case = FALSE, engine = getOption("gsubfn.engine"),
    env = parent.frame(), ...)

The user can put an options(engine = "...whatever...") in their
.Rprofile file or can enter it interactively into R.  If not,
getOption("gsubfn.engine") returns NULL and the gsubfn package can
check whether engine was passed as a NULL and supply a default.

-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com



[Rd] how to store package options over sessions?
Gabor Grothendieck