Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
narrenfrei opened this issue Sep 22, 2014 · 1 comment
Closed

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

narrenfrei opened this issue Sep 22, 2014 · 1 comment
Assignees
Labels
Milestone

Comments

@narrenfrei
Copy link

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.

@narrenfrei
Copy link
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants