setkeys: setkeys - change/rename the keys of a hash

Description Usage Arguments Value Note See Also Examples

Description

Changes the keys of a hash from old keys to new

Usage

1
2
3
4
setkeys(x, old, new)

## S4 method for signature 'hash'
setkeys(x, old, new)

Arguments

x

hash object to rename keys on

old

character (or coerciable to character); old keys/names

new

character (or coerciable to character); new keys/names

This methods renames keys in a hash. If there is a collision between old and new names, the old names are first copied to a temporary slot to ensure

setkeys is S4 generic so that other packages might also use the generic functions

Value

Invisiblly returns x with its keys renamed.

Note

setkeys is modeled after setnames in the data.table package.

See Also

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
   h <- hash( letters, 1:26 )
   
   h2 <- copy(h)
   setkeys( h2, keys(h), paste0( keys(h), "1" ) )
   h2 
   
   h3 <- copy(h)
   setkeys( h3, keys(h), rev( keys(h) ) )
   h3 
   

decisionpatterns/r-hash documentation built on Feb. 6, 2019, 10:27 p.m.