Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upretain attributes while chaining #995
Comments
|
Have marked as FR for now. |
|
new SO about that: https://stackoverflow.com/questions/33441632/retaining-metadata-when-subsetting-in-data-table edit: another new one: https://stackoverflow.com/questions/34318299/user-specified-attributes-of-data-table-get-removed |
|
Guy, is there are any problems with a solution like the following? First, adding a function that will copy required attributes: retainAttributes <- function(x, ans) {
if ("retain.attributes" %in% names(attributes(x))) {
for (a in c(attr(x, "retain.attributes"), "retain.attributes")) {
attr(ans, a) <- attr(x, a)
}
}
ans
}And then using it is as a wrapper when neccessary in
With these, the following scenario works:
I can't provide a full patch, as |
|
Interesting idea, but d1=data.table::data.table(a=1)
data.table::address(d1)
attr(d1, "asd") <- "qwe"
data.table::address(d1) |
|
@jangorecki Could you explain a little bit more? I have the same address printed there:
What's get copied there? |
|
But it's just for my education, I have no problems with changing |
|
That is strange, when I was calling that before I get different address and now I'm getting the same. I must have made some wrong then. |
|
want this feature very much, it's not available yet? |
|
+1 for this features. Any concerns about solution above? |
|
+1 for this feature also from my side. I am not an expert with
|
Question / Feature request.
Any tricky way to retain attributes when chaining? of course not all should be retained ("index","sorted","names", etc.).
So the Feature request would be about retaining all user defined (non-DT related: "sorted","index", etc.) attributes.
Or maybe retain attrs defined by name, something like
This would allow to store custom metadata together with data.table, possibility reuse them while processing, or manipulate when using
DT[,f(.SD)].