Description Usage Arguments Author(s) See Also Examples
These are the hash accessor methods. They closely follow the R style.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | ## S4 method for signature 'hash,ANY,missing,missing'
x[i, j, ..., drop = TRUE]
## S4 method for signature 'hash,missing,missing,missing'
x[i, j, ..., drop = TRUE]
## S4 replacement method for signature 'hash,ANY,missing,ANY'
x[i, j, ...] <- value
## S4 replacement method for signature 'hash,ANY,missing,'NULL''
x[i, j, ...] <- value
## S4 replacement method for signature 'hash,'NULL''
x$name <- value
## S4 replacement method for signature 'hash,ANY,missing,ANY'
x[[i]] <- value
## S4 replacement method for signature 'hash,ANY,missing,'NULL''
x[[i]] <- value
|
x |
|
i |
keys to get or set |
j |
unused; retained to be compatoble with base package |
... |
Arguments passed to additional methods |
drop |
unused; retained to be compatible with base package |
value |
the value to set for the key-value pair |
name |
the key name
All hash key misses return
See details above for the complete explanation. |
Christopher Brown
del()
for removing keys
clear()
for removing all keys
keys()
to get/set/rename keys
values()
to get/set/edit values
hash()
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 | h <- hash( c('a','b','c'), 1:3 )
# NAMED ACCESS
h$a # 1
h$c # 3
# class of values change automatically
class(h$a) # integer
h$a <- 1.1
class(h$a) # numeric
# values can contain more complex objects
h$a <- 1:6
h
h$a <- NULL # DELETE key 'a', will return null
# INTERPRETED ACCESS
h[[ "a" ]] <-"foo" # Assigns letters, a vector to "foo"
nm = "a"
# SLICE ACCESS
h[ nm ] <- "bar" # h$a == bar
h[ nm ] <- NULL
# Slice
h[ keys(h) ]
h[ keys(h) ] <- list( 1:2, 1:3 )
h
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.