Skip to content

[R-Forge #5408] as.data.table.table creates names in an incorrect order #43

@arunsrinivasan

Description

@arunsrinivasan

Submitted by: Benjamin Barnes; Assigned to: Arun ; R-Forge link

The names of the resulting data.table are in the incorrect order. For example,

set.seed(123)

DT <- data.table(XX = sample(LETTERS[1:5], 1000, replace = TRUE),
    yy = sample(1:5, 1000, replace = TRUE))

as.data.table(DT[, table(XX, yy)])
## Names are c("yy", "XX", "N")
## Should be c("XX", "yy", "N"), as in as.data.frame

sessionInfo()

# R version 3.0.2 (2013-09-25)
# Platform: x86_64-w64-mingw32/x64 (64-bit)

# locale:
# [1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252   
# [3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C                   
# [5] LC_TIME=German_Germany.1252    

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

# other attached packages:
# [1] data.table_1.9.2

# loaded via a namespace (and not attached):
# [1] plyr_1.8.1     Rcpp_0.11.0    reshape2_1.2.2 stringr_0.6.2  tools_3.0.2

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions