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

melt drops the class of integer64 columns #993

Closed
richierocks opened this issue Dec 29, 2014 · 4 comments
Closed

melt drops the class of integer64 columns #993

richierocks opened this issue Dec 29, 2014 · 4 comments
Assignees
Milestone

Comments

@richierocks
Copy link

To reproduce, try:

DT <- data.table(x = as.integer64(10^(9:18)))
##                       x
##  1:          1000000000
##  2:         10000000000
##  3:        100000000000
##  4:       1000000000000
##  5:      10000000000000
##  6:     100000000000000
##  7:    1000000000000000
##  8:   10000000000000000
##  9:  100000000000000000
## 10: 1000000000000000000

melt(DT, measure.vars = "x")
##     variable         value
##  1:        x 4.940656e-315
##  2:        x 4.940656e-314
##  3:        x 4.940656e-313
##  4:        x 4.940656e-312
##  5:        x 4.940656e-311
##  6:        x 4.940656e-310
##  7:        x 4.940656e-309
##  8:        x 5.431165e-308
##  9:        x 5.620396e-302
## 10:        x 7.832953e-242

integer64 values are stored using numeric values. The numbers shown in the value column after melting are unclass(DT$x).

@arunsrinivasan
Copy link
Member

Thanks. melt up until 1.9.4 did not preserve attributes (this is also documented), to be consistent with reshape2. I'll try to commit the newer implementation of melt in 1.9.6 - and that preserves attributes as expected.

If not, it'll most likely be in 1.9.8.

@richierocks
Copy link
Author

OK, thanks. I get the same behaviour with Date and POSIXct objects, but not with factors (which appear as characters not integers). It might be worth including tests on these types with your new version of melt.

@arunsrinivasan
Copy link
Member

Yes. It was to be consistent with inconsistency of melt from reshpe2. But I won't do that anymore.

@arunsrinivasan
Copy link
Member

This commit 07b90de fixes it. melt now retains attributes wherever possible.

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

No branches or pull requests

2 participants