Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign up
The comparison of two data.tables yields a matrix for which the value returned by colnames() changes when columns are added by reference to the leftmost data.table which the matrix was created from. Specifically, consider that
a <- b <- data.table(X=1:2). Then,x <- a==b; print(x)returns a matrixand
colnames(x)returns"X"as expected. Adding the column Y asa[, Y:=1]results incolnames(x)returning print(x)returning"X" "Y", even thoughprint(x)still returns the same as above. Further, this does not happen if the column is added asa$Y <- 1` or if the column is added to b instead. I have not managed to reproduce the problem with data.frames, thus the chances are this is a problem that can be solved here.#Minimal reproducible example#Output of sessionInfo()R version 3.6.2 (2019-12-12)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.6 LTS
Matrix products: default
BLAS: /usr/lib/openblas-base/libblas.so.3
LAPACK: /usr/lib/libopenblasp-r0.2.18.so
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=fi_FI.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=fi_FI.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=fi_FI.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=fi_FI.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] data.table_1.12.8
loaded via a namespace (and not attached):
[1] compiler_3.6.2