clone: Clone an lvec object

View source: R/clone.R

cloneR Documentation

Clone an lvec object

Description

Clone an lvec object

Usage

clone(x, ...)

## S3 method for class 'lvec'
clone(x, ...)

Arguments

x

lvec object to clone

...

ignored; used to pass additional arguments to other methods

Details

lvec objects are basically pointers to pieces of memory. When copying an object only the pointer is copied and when modifying the copied object also the original object is modified. The advantage of this is speed: these is less copying of the complete vector. In order to obtain a true copy of an lvec code can be used.

Examples

a <- as_lvec(1:3)
# Copy
b <- a
# When modifying the copy also the original is modified
lset(b, 1, 10)
print(a)
print(b)
# Use clone to make a true copy
b <- clone(a)
lset(b, 1, 100)
print(a)
print(b)


lvec documentation built on Nov. 10, 2022, 6:18 p.m.

Related to clone in lvec...