[datatable-help] Fwd: problems with modifying colnames

Francois Pepin fpepin at gmail.com
Fri Jul 25 03:27:12 CEST 2014


Hi everyone,

I’m hitting a weird bug which I think might be data.table’s fault.

x<-data.table(a=1,b=2)
xn<-colnames(x)
xn
#[1] "a" "b"
x[,c:=3]
xn
[1] "a" "b" "c"


I would expect xn to stay the same value even if we change the columns in x.

There’s an easy workaround with copy(xn), but it’s weird and
surprising enough that I wanted to let others know about it.

Could someone check to see if this is reproducible? I’ll be happy to
file the bug report if it’s a genuine bug.

Thanks,

Francois

R version 3.1.0 (2014-04-10)
Platform: x86_64-unknown-linux-gnu (64-bit)

locale:
[1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8       LC_NAME=C
[9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] data.table_1.9.3

loaded via a namespace (and not attached):
[1] plyr_1.8.1    Rcpp_0.11.2   reshape2_1.4  stringr_0.6.2


More information about the datatable-help mailing list