Learn R Programming

bit (version 4.0.3)

copy: Copy atomic R vector

Description

Creates a true copy of the underlying C-vector -- dropping all attributes -- and optionally reverses the direction of the elements.

Usage

copy(x, revx = FALSE)

Arguments

x

an R vector

revx

default FALSE, set to TRUE to reverse the elements in 'x'

Value

copied R vector

Details

This can be substantially faster than duplicate(as.vector(unclass(x)))

See Also

clone, still.identical, reverse

Examples

Run this code
# NOT RUN {
x <- factor(letters)
y <- x
z <- copy(x)
still.identical(x,y)
still.identical(x,z)
str(x)
str(y)
str(z)
# }

Run the code above in your browser using DataLab