On 14/01/2020 11:06 a.m., Jonathan Greenberg 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.

You can read ?Startup to see what happens when R starts up. Putting environment variables in .Renviron would work; so would putting R code in .Rprofile. However, those files both belong to the user, so your package shouldn't write to them without asking, and it's probably better not to write there at all.

A few packages put cached information into a ~/.R directory; I'd suggest putting your stuff into ~/.R/gdaUtils/* (after asking for permission).

Duncan Murdoch

______________________________________________
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel

Reply via email to