Learn R Programming

maditr (version 0.8.4)

copy: Copy an entire object

Description

Mainly intended to copy data.table objects because by default they are modified by reference. See example.

Usage

copy(x)

Value

copy of the object 'x'

Arguments

x

object

Examples

Run this code
data(mtcars)
dt_mtcars = as.data.table(mtcars)
dt_mtcars2 = dt_mtcars
dt_mtcars3 = copy(dt_mtcars)
let(dt_mtcars, new = 1)

head(dt_mtcars2) # we see 'new' column
head(dt_mtcars3) # no 'new' column

Run the code above in your browser using DataLab