[datatable-help] setnames on copy data.table also renames original data.table object

Manabu Sakamoto manabu.sakamoto at gmail.com
Mon Mar 10 06:00:43 CET 2014


Dear list,

I have a data.table object for instance DT:

x <- seq(1:100)
y <- x^2
DT <- data.table(X=x, Y=y)

and I produce a copy

DT2 <- DT

which I rename

setnames(DT2, c("A","B"))

this somehow also renames DT, the names of which are now "A" and "B".

How can I just rename the copy and keep the names of the original?

Many thanks,
Manabu

-- 
Manabu Sakamoto, PhD
manabu.sakamoto at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/datatable-help/attachments/20140310/bd40d1cf/attachment.html>


More information about the datatable-help mailing list