Skip to content

cast changes column name of origin input data.table #825

Description

@narrenfrei

After using cast (out of reshape) the column names of a data.table has changed.

tmp <- data.table(
    ID = c(611557L, 611557L, 611557L, 894125L, 894125L, 894125L, 894125L, 894125L, 898856L, 898856L, 898856L, 898856L, 898856L, 898856L, 898899L, 898899L, 898899L), 
    DATUM = structure(c(16101, 16071, 16261, 16104, 16133, 16167, 16201, 16236, 16089, 16118, 16147, 16176, 16236, 16208, 16163, 16125, 16209), class = "Date"), 
    N = c(25L, 9L, 23L, 29L, 26L, 26L, 27L, 28L, 39L, 39L, 38L, 36L, 40L, 39L, 19L, 20L, 19L), 
    rank = c(2, 1, 3, 1, 2, 3, 4, 5, 1, 2, 3, 4, 6, 5, 2, 1, 3)
)
names(tmp)
# [1] "ID"    "DATUM" "N"     "rank" 
cast(tmp, ID ~ rank, value = "DATUM")
names(tmp)
# [1] "ID"    "value" "N"     "rank" 

Using dcast (out of reshape2) for the data.table or cast (out of reshape) for a data.frame don't change anything.

Activity

  1. narrenfrei commented on Sep 22, 2014

    @narrenfrei
    Author

    Sorry for missing information:
    data.table 1.9.3
    reshape 0.8.5
    I'm working on MAC OS X 10.9.4 (Platform: x86_64-apple-darwin13.1.0 (64-bit)) with a new installed R 3.1.1

  2. added this to the v1.9.6 milestone on Sep 23, 2014
  3. added a commit that references this issue on Oct 3, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions