| temp_env {svMisc} | R Documentation | 
Get an environment dedicated to temporary variables (and create it if needed)
Description
Create and manage a temporary environment SciViews:TempEnv
low enough on the search path so that all loaded packages (except base)
could easily access objects there.
Usage
temp_env()
add_items(x, y, use.names = TRUE, replace = TRUE)
add_temp(x, item, value, use.names = TRUE, replace = TRUE)
assign_temp(x, value, replace.existing = TRUE)
change_temp(x, item, value, replace.existing = TRUE)
exists_temp(x, mode = "any")
get_temp(x, default = NULL, mode = "any", item = NULL)
delete_temp(x)
rm_temp(x)
TempEnv()
addItems(x, y, use.names = TRUE, replace = TRUE)
addTemp(x, item, value, use.names = TRUE, replace = TRUE)
assignTemp(x, value, replace.existing = TRUE)
changeTemp(x, item, value, replace.existing = TRUE)
existsTemp(x, mode = "any")
getTemp(x, default = NULL, mode = "any", item = NULL)
rmTemp(x)
Arguments
| x | The vector to add items to for  | 
| y | The vector of which we want to inject missing items in 'x'. | 
| use.names | Use names of items to determine which one is unique, otherwise, the selection is done on the items themselves. | 
| replace | Do we replace existing items in 'x'? | 
| item | The item to add data to in the list. | 
| value | The value to add in the item, it must be a named vector and element matching is done according to name of items. | 
| replace.existing | Do we replace an existing variable? | 
| mode | The mode of the seek variable | 
| default | The default value to return, in case the variable or the item does not exist. | 
Details
The temporary environment is attached to the search path for easier access to its objects.
Value
The temporary environment for temp-env(), the value assigned, added
or changed for assign_temp(), add_temp(), change_temp(), or
get_temp(). TRUE or FALSE for exists_temp(), delete_temp() or
rm_temp().
See Also
assign(), search(), temp_var()
Examples
ls(temp_env())
# I have a vector v1 with this:
v1 <- c(a = "some v1 text", b = "another v1 text")
# I want to add items whose name is missing in v1 from v2
v2 <- c(a = "v2 text", c = "the missign item")
add_items(v1, v2, replace = FALSE)
# Not the same as
add_items(v1, v2, replace = TRUE)
# This yield different result (names not used and lost!)
add_items(v1, v2, use.names = FALSE)
add_temp("tst", "item1", c(a = 1, b = 2))
# Retrieve this variable
get_temp("tst")
# Add to item1 in this list without replacement
add_temp("tst", "item1", c(a = 45, c = 3), replace = FALSE)
get_temp("tst")
# Same but with replacement of existing items
add_temp("tst", "item1", c(a = 45, c = 3), replace = TRUE)
get_temp("tst")
# Delete the whole variable
delete_temp("tst")
assign_temp("test", 1:10)
# Retrieve this variable
get_temp("test")
change_temp("tst", "item1", 1:10)
# Retrieve this variable
get_temp("tst")
# Create another item in the list
change_temp("tst", "item2", TRUE)
get_temp("tst")
# Change it
change_temp("tst", "item2", FALSE)
get_temp("tst")
# Delete it (= assign NULL to the item)
change_temp("tst", "item2", NULL)
get_temp("tst")
# Delete the whole variable
delete_temp("tst")
assign_temp("test", 1:10)
# Check if this variable exists
exists_temp("test")
# Remove it
delete_temp("test")
# Does it still exists?
exists_temp("test")