copy: copy

Description Usage Arguments Value Author(s) See Also Examples

Description

Create a copy of a hash.

Usage

1
2
3
4
copy(x, ...)

## S4 method for signature 'hash'
copy(x, ...)

Arguments

x

hash

...

additional arguments

Creatinga copy using the assingment operator, <-, does not work as expected, since hashes are based on environments and environments are reference objects in R. The assignment operator consequently creates a linked copy the original hash and not an independent copy. The copy method provides an identical unlinked copy of the hash.

Value

hash, copy of hash x

Author(s)

Christopher Brown

See Also

base::environment()

Examples

1
2
3
4
5
6
7
8
9
  h <- hash( a=1, b=2 )
  g <- h
  g$a <- "foo"
  h$a     # "foo" 
  
  h_new <- copy( h )
  h_new$a <- "bar"
  h$a     # still "foo"
  

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