Description Usage Arguments Details Value See Also Examples
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.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | 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)
 | 
| 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. | 
The temporary environment is attached to the search path for easier access to its objects.
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().
assign(), search(), temp_var()
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | 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")
 | 
Attaching package: 'svMisc'
The following object is masked from 'package:utils':
    ?
character(0)
                 a                  b                  c 
    "some v1 text"  "another v1 text" "the missign item" 
                 a                  c                  b 
         "v2 text" "the missign item"  "another v1 text" 
[1] "another v1 text"  "some v1 text"     "the missign item" "v2 text"         
$item1
a b 
1 2 
$item1
a b c 
1 2 3 
$item1
 a  c  b 
45  3  2 
 [1]  1  2  3  4  5  6  7  8  9 10
$item1
 [1]  1  2  3  4  5  6  7  8  9 10
$item1
 [1]  1  2  3  4  5  6  7  8  9 10
$item2
[1] TRUE
$item1
 [1]  1  2  3  4  5  6  7  8  9 10
$item2
[1] FALSE
$item1
 [1]  1  2  3  4  5  6  7  8  9 10
[1] TRUE
[1] FALSE
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.