Skip to content

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

@narrenfrei

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.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions