Learn R Programming

DTSg (version 2.0.0)

clone.DTSg: Clone object

Description

Clones (copies) a DTSg object. Merely assigning a variable representing a DTSg object to a new variable does not result in a copy of the object. Instead, both variables will reference and access the same data under the hood, i.e. changing one will also affect the other. This is not an issue when calling methods with the DTSgClone option or clone argument set to TRUE, but has to be kept in mind when setting fields, as they are always modified in place. See DTSg for further information.

Usage

# S3 method for DTSg
clone(x, deep = FALSE, ...)

Value

Returns a cloned DTSg object.

Arguments

x

A DTSg object (S3 method only).

deep

A logical specifying if a deep copy shall be made (for consistency with the R6::R6Class the default is FALSE, but should generally be set to TRUE).

...

Not used (S3 method only).

See Also

Examples

Run this code
# new DTSg object
x <- DTSg$new(values = flow)

# make a deep copy
## R6 method
x$clone(deep = TRUE)

## S3 method
clone(x = x, deep = TRUE)

Run the code above in your browser using DataLab