-
Notifications
You must be signed in to change notification settings - Fork 991
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
the class of objects inherited from data.table in list column may get changed #4324
Comments
Thanks for filling out the report. |
Sorry. I ran it again without loading everything. Same result. Code:
Result:
|
If the element inside the list is also a data.table object, the other class attributes will be removed when the element is touched inside The mini repro examplelibrary(data.table)
val_dt <- data.table(COL = 'dt')
class(val_dt) <- c('aaa', class(val_dt))
val_df <- data.frame(COL = 'df', stringsAsFactors = FALSE)
class(val_df) <- c('aaa', class(val_df))
dt <- data.table(
A = 1:2,
B = list(val_dt, val_dt),
C = list(val_df, val_df)
)
dt
#> A B C
#> <int> <list> <list>
#> 1: 1 <aaa[1x1]> <aaa[1x1]>
#> 2: 2 <aaa[1x1]> <aaa[1x1]>
dt[1, B[[1]]]
#> COL
#> <char>
#> 1: dt
dt[1, C[[1]]]
#> COL
#> 1 df
dt
#> A B C
#> <int> <list> <list>
#> 1: 1 <data.table[1x1]> <aaa[1x1]>
#> 2: 2 <aaa[1x1]> <aaa[1x1]> Created on 2020-03-28 by the reprex package (v0.3.0) |
Just a note to myself, there're actually two issues, considering
After a 2nd though, the no.2 point may be expected behavior, as the user should be aware of that. I'm looking forward to your inputs. |
Any progress on this? I see shrektan noted "looking forward to your inputs". Does this mean you are waiting for me or someone on the data.table team? I'm not intending to be pushy but am having to work around the issue in a package under development and my life would be much easier if I could rely on the attribute being retained. |
@HJAllen The issue you bring up should have been addressed by #4354 but I think the PR needs @mattdowle 's review before merging it. In the meantime, you could use the PR version via |
Thanks! I will give it a try. |
I confirm that the fix solves the problem. Thanks! |
lets not close this issue till the fix is not yet merged to master branch |
Sorry to bother, but any idea when this might get merged? |
@jangorecki Any updates on why the fix by @shrektan can not be merged? I just ran into the same problem in a real-world scenario. I see there are some merge conflicts but all of them is trivial to resolve (willing to help if required). |
@tdeenes AFAIK the fix can be merged, it is just that we have a long queue of open PRs. |
I am developing a class inheriting data.table but having trouble with the derived class being dropped. As can be seen in the example, when assigning the derived class to a list column, the class is initially retained but is subsequently dropped. Interestingly, it is only dropped for elements upon which an evaluation is performed.
I found one SO thread discussing similar but stated the issue had been resolved in 1.9.4. I am using 1.12.8.
https://stackoverflow.com/questions/24881842/deriving-a-new-class-from-data-table
Is this expected behavior?
#
Minimal reproducible example
#
Output of sessionInfo()
The text was updated successfully, but these errors were encountered: