[R] Available environment variables

Duncan Murdoch murdoch at stats.uwo.ca
Thu Dec 20 20:36:14 CET 2007

On 20/12/2007 2:13 PM, Thompson, David (MNR) wrote:
> Hello,
> I am trying to set my environment to streamline the downloading /
> updating of packages. I have been through R-intro.html (10.8
> Customizing-the-environment), R-FAQ (5.2 How can add-on packages be
> installed?), rw-FAQ, and help pages for Sys.setenv {base},
> download.packages {utils}, etc.,.
> I am looking for something similar to the download.packages destdir
> argument on a global environment level, e.g., destdir <- 'C:/Program
> Files/_dave/stats/R/library/_download' in Rprofile.site. Any
> suggestions?

You could create your own function:

download.packages <- function(pkgs, destdir='C:/Program 
Files/_dave/stats/R/library/_download', ...)
   utils::download.packages(pkgs, destdir, ...)

> Also, in a more general context, is there a way of listing all available
> (or common, or default, or standard, . . .) environment variables?

Sys.getenv() will return a list of the ones that are currently defined.
> would like to know if there is an existing convention for any arbitrary
> process that I may try to do without reinventing the wheel. This same
> question could apply to options() other than those included with a
> standard installation.

I don't know what you mean about an "arbitrary process".

For options(), you could save the names that you consider standard (e.g. 
by starting an empty session and entering standardoptions <- 
names(options()), then at a later time do

newoptions <- names(options())
newoptions[ !(newoptions %in% standardoptions) ]

There's no easy way to know the options that would mean something in the 
current context but are not currently defined.

Duncan Murdoch

More information about the R-help mailing list