clone physically duplicates objects and can additionally change
some features, e.g. length.
clone(x, ...)
# Default S3 method
clone(x, ...)an object that is a deep copy of x
clone is generic. clone.default handles ram objects.
Further methods are provided in package 'ff'.
still.identical returns TRUE if the two atomic arguments still
point to the same memory.
clone(default): default method uses R's C-API 'duplicate()'
clone.ff, copy_vector()
x <- 1:12
y <- x
still.identical(x, y)
#> [1] TRUE
y[1] <- y[1]
still.identical(x, y)
#> [1] FALSE
y <- clone(x)
still.identical(x, y)
#> [1] FALSE
rm(x, y); gc()
#> used (Mb) gc trigger (Mb) max used (Mb)
#> Ncells 1280481 68.4 1943068 103.8 1943068 103.8
#> Vcells 8166234 62.4 22625036 172.7 25049960 191.2