options_attach: Attachment with update of options

Description Usage Arguments Value

View source: R/options_attach.R

Description

This function is a wrapper around attach, that in addition performs an update of the options. The idea is that an option can store the names of several attached objects, and latter on when it's time to clean up it should be sufficient to specify the relevant option in order to detach. Note that the function performs a sanity-check to ensure that no options set by other packages should be affected. The defaults for those arguments that are to be sent to attach, are inherited from that function.

Usage

1
2
3
options_attach(what, pos = 2L, name = deparse(substitute(what)),
  warn.conflicts = TRUE, options_name, options_front = TRUE,
  replace = TRUE)

Arguments

what

The object to attach. Note: This argument will be sent to the what-argument of attach.

pos

The position in search() at which the object will be attached. Note: This argument will be sent to the pos-argument of attach.

name

The name to use for the attached object. Names starting with package: are reserved for library. If the search path already has an object named name, then a minor adjustment will be made to ensure that the cleaning done by options_detach doesn't remove the wrong alternative. Note: This argument will be sent to the name-argument of attach.

warn.conflicts

Logical argument. When this is TRUE, warnings will be printed about conflicts from attaching what. A conflict is a function masking a function, or a non-function masking a non-function. Note: This argument will be sent to the warn.conflicts-argument of attach.

options_name

A character string that specifies the name of the option to be used when storing the names of the attached environments. Note that options_name will be tested against options added by other packages, and that an error will be called if there's an overlap - in particular, this function will not mess up any options set by other packages. A "stacking" procedure will be used if options_name already has been created before (by this function), and the way the stacking is done is governed by the options_front-argument.

options_front

A logical value, default FALSE, that decides how a new name should be added to options_name (when an earlier use of options_attach already created an occurrence of options_name).

replace

A logical value, default TRUE. This can be used to check that earlier versions of the attached environment (with the same combination of name and options_name) will be detached before the new environment specified by what is added.

Value

When successful, the function will attach the object specified in what and add its name to the option options_name as specified by options_front. Depending on the value of replace, any old attached environment with the same name as the present one will be replaced. Note: No replacement will be done if the new and the old environment contains the same content. If the positional order on the search-path is important, that might require that the existing environment has to be detached first.


LAJordanger/UnderConstruction documentation built on May 3, 2019, 5 p.m.