Re: [Rd] how to store package options over sessions?

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Mon, 22 Nov 2010 11:34:59 -0500

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

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Mon 22 Nov 2010 - 16:39:10 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 22 Nov 2010 - 17:00:24 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive