getTemp {svMisc}R Documentation

Get a temporary variable from the TempEnv environment

Description

The function gets a variable, or an item in a list variable from TempEnv, an environment dedicated to temporary variables.

Usage

    getTemp(x, default = NULL, mode = "any", item = NULL)

Arguments

x The name of the variable
default The default value to return, in case the variable or the item does not exist
mode The mode of the variable or the item (if the variable exists, but is not of correct mode, the default value is returned). Use mode = "any" (default value) to retrieve the variable or item whatever its mode.
item if NULL (default), the whole variable content is retrieve, otherwise, the variable is considered as a list, and the corresponding item from that list is returned. In this case, default and mode arguments correspond to the item, not to the whole variable.

Value

The content of the variable, of the item, or the default value if the variable or item is not found in TempEnv, or of the wrong mode.

Author(s)

Philippe Grosjean <phgrosjean@sciviews.org>

See Also

TempEnv, assignTemp, changeTemp, rmTemp, existsTemp, addTemp

Examples

assignTemp("test", 1:10)
# Retrieve this variable
getTemp("test")
# Retrieve a non existing variable (returns default value)
getTemp("nonexistant", default = "default value")
# Set and retrieve items from a list
changeTemp("test2", "item1", 1:5)
getTemp("test2", item = "item1")
# Compare to:
getTemp("test2")
# Remove temporary variables
rmTemp(c("test", "test2"))

[Package svMisc version 0.9-46 Index]