In `mudim` parkage, all objects (distributions, models) refered by *reference*. That is, if a variable is assigned to an other one, no copy is made at all. Both new variables refer to the same object.

copy(x)

# S3 method for Model
copy(x)

Arguments

x

Distribution, Compositional model

Value

Returns a copy of the object

Details

`mudim` provides functions and that operate on objects *by reference* and minimize full object copies as much as possible. Still, it might be necessary in some situations to work on an object's copy which can be done using `d.copy <- copy(d)`. Assume command `d.copy <- d`. Due to R's *copy-on-modify* policy, `d.copy` still points to the same location in memory as `d`. Therefore modifying `d.copy`, say by changing variables names, `d` will also get updated. To avoid this, one has to *explicitly* copy: `d.copy <- copy(d)`.

Methods (by class)

  • Model: Copy compositonal model

Examples

data(Pi) variables(Pi)
#> [1] "A" "B"
Pi.copy <- Pi variables(Pi.copy) <- c("C","D") variables(Pi)
#> [1] "C" "D"
Pi.copy <- copy(Pi) variables(Pi.copy) <- c("E","F") variables(Pi)
#> [1] "C" "D"