Creates a deep copy of an object, as an external pointer, for instance a tokens_xptr class object.

copy(x)

Arguments

x

the input object to be copied

Value

an entire copy of x, by value

Examples

xtoks <- tokens(data_corpus_inaugural[1:3], xptr = TRUE)
print(xtoks, 0, 0)
#> Tokens consisting of 3 documents and 4 docvars (pointer to 0x12182a588).

# shallow copy
xtoks_shallow <- xtoks
print(xtoks_shallow, 0, 0)
#> Tokens consisting of 3 documents and 4 docvars (pointer to 0x12182a588).

# deep copy
xtoks_deep <- copy(xtoks)
print(xtoks_deep, 0, 0)
#> Tokens consisting of 3 documents and 4 docvars (pointer to 0x121e72578).