[R-pkg-devel] Proper way to ask a user to set permanent variables?

Rainer M Krug R@|ner @end|ng |rom krug@@de
Wed Jan 15 08:39:39 CET 2020


I second that - it provides the most consistent way of storing information permanently.

I was in a similar situation, and ended up using the function at 

https://github.com/Exp-Micro-Ecol-Hub/dmdScheme/blob/master/R/cache.R <https://github.com/Exp-Micro-Ecol-Hub/dmdScheme/blob/master/R/cache.R>

And the location `rappdirs::user_config_dir(appname = "dmdScheme", appauthor = "dmdScheme”)` as the permanent cache.

I either either 
- use a temporary cache if the cache does not exist
- if the cache does exist, use that one, and
- use the `createPermanent` argument to create the cache so that it can be used.

Cheers,

Rainer


> On 14 Jan 2020, at 17:34, Gábor Csárdi <csardi.gabor using gmail.com> wrote:
> 
> You can use the rappdirs package to look up the standard places for
> permanent config, cache etc. files. E.g. on macOS:
> 
> ❯ rappdirs::user_cache_dir()
> [1] "/Users/gaborcsardi/Library/Caches"
> 
> Gabor
> 
> On Tue, Jan 14, 2020 at 4:10 PM Jonathan Greenberg <jgreenberg using unr.edu> wrote:
>> 
>> Folks:
>> 
>> My package gdalUtils is a wrapper for a set of binaries on disk (the GDAL Utilities) -- these have about as many places to install as there are people installing it, and the system environment variables aren't always much help (they aren't always set) for locating them.  My package is trying to dummy-proof the usage as much as possible, so one of the things it does is if it can't find the install, it goes search for the install in, first, standard locations and runs a short test to see if the install is valid and, if not, goes on a longer hunt.  Right now, it does this search everytime someone boots up R and uses it, which slows down the process.
>> 
>> What I'm wondering is twofold:
>> 
>> 1) Are there any packages/methods by which user "preferences" are saved that don't require saving workspaces (e.g. does R have a standardized "preferences" location that packages can use).
>> 
>> 2) If the answer to #1 is "no", what is the preferred method for saving variables for use by packages that are always restored on boot -- e.g. I was thinking something like .Renviron but I think that's Rstudio only.  I'm concerned with workspace-type saves since I feel like that often results in a ton of variables being saved.
>> 
>> Thanks!
>> 
>> --j
>> 
>>        [[alternative HTML version deleted]]
>> 
>> ______________________________________________
>> R-package-devel using r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-package-devel
> 
> ______________________________________________
> R-package-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel

--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)

Orcid ID: 0000-0002-7490-0066

Department of Evolutionary Biology and Environmental Studies
University of Zürich
Office Y34-J-74
Winterthurerstrasse 190
8075 Zürich
Switzerland

Office:	+41 (0)44 635 47 64
Cell:       	+41 (0)78 630 66 57
email:      Rainer.Krug using uzh.ch
		Rainer using krugs.de
Skype:     RMkrug

PGP: 0x0F52F982




	[[alternative HTML version deleted]]



More information about the R-package-devel mailing list