[Rd] Suggestions for an "official" place to store permissions/options for a package?

Milan Bouchet-Valat nalimilan at club.fr
Sat Oct 19 13:47:03 CEST 2013

Le vendredi 18 octobre 2013 à 19:32 -0500, Jonathan Greenberg a écrit :
> R-developers:
> Duncan Murdoch suggested I move a post I started on r-help over here,
> since it is more at the developer level.  Here is my
> question/challenge -- to my knowledge, there is not currently an
> official way to store a *package*'s options to a standardized location
> on a user's computer.  Given that OS-level programs have standard
> preference locations, I was hoping to first assess:
> - Does R, in fact, have a place for a *package* to store preferences
> (a file-based "setOptions") that would be persistent across sessions.
> One suggestion that was given was to perhaps write these options to
> the .RProfile, but this strikes me as potentially dangerous -- a
> poorly written function to write to a user's .RProfile could corrupt
> it.
> If the answer to the initial question is "no" (there is not an
> official location/approach for a package to store its own files), I'd
> like to suggest we open this for a wider discussion amongst the
> developers, to perhaps come up with a general (not package-by-package)
> solution for a package to store options (and perhaps other files) in a
> standard location.
> The particular application that has brought me to asking about this is
> that I'm writing a package that has external calls to command-line
> programs that may not be properly registered with a user's environment
> (think: Windows, in particular, although I've found issues with a Mac
> as well), so the first step of these R - wrapper functions is to
> search a user's local machine for the binaries.  If it finds it, it
> stores the path to this binary as an option.  Since this is a
> brute-force search, this can take some time and, ideally, this
> information would be preserved across sessions, without the function
> having to re-search their drive every time they start R fresh.
I support this request. This would be useful for Rcmdr and Rcmdr
plug-ins to save GUI preferences in a cleaner fashion than writing
to .Rprofile. A major use case for R base itself would be to store the
default CRAN mirror once for all instead of asking the user every time
(s)he installs a package.

Any mechanism will do, from a simple .ini style key-value file to
serializing and restoring an arbitrary (but usually very simple) R
object. .Rprofile is really not designed to store preferences. A
per-package way of saving settings would mean that a package has no
chance of messing with the user's global settings when it is not loaded,
reducing the risk of breakage.


More information about the R-devel mailing list