-
Notifications
You must be signed in to change notification settings - Fork 977
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
[R-Forge #5252] rbindlist should support expression columns #546
Comments
could be handled by more generic solution described in #1302 |
Looked into this a bit. Actually not straightforward because
I guess that looks a bit puzzling, but it's because If we change the default Any ideas @jangorecki? Or should we |
I think we agree on API of such complex structure, in was discussed in #1302 and related PR. a <- data.table(c1 = 1, c2 = 'asd', c3 = expression(as.character(Sys.time())))
b <- data.table(c1 = 3, c2 = 'qwe', c3 = expression(as.character(Sys.time()+5)))
c(a$c3, b$c3)
#expression(as.character(Sys.time()), as.character(Sys.time() + 5))
# this is not what we wanted!
c(list(a$c3), list(b$c3))
# this one is! so the proper way is to prohibit to create expression column that is not wrapped into list column. |
Playing around with this now a bit more & seems possible & not too difficult actually. |
This issue has not been resolved by #3981. data.table(c1 = c(1, 3), c2 = c("asd", "qwe"), c3 = list(
expression(as.character(Sys.time())), expression(as.character(Sys.time() + 5))
)) while the PR #3811 produce the following output data.table(c1 = c(1, 3), c2 = c("asd", "qwe"), c3 = expression(
as.character(Sys.time()), as.character(Sys.time() + 5)
)) It was reported by me in PR which has been merged without further discussion. |
All I remember seeing was that you thought it wouldn't be needed by anyone (#3811 (review)). I saw it wasn't marked WIP, was passing tests, so I merged it to make progress and out of the way. @MichaelChirico, are you able to see a solution? |
I think I have a working solution:
This means any type not listed in the typeorder in src/init.c (e.g EXPRSXP) will be coerced into a list. As an aside, I think we could safely reduce the |
Actually it looks like
Target behaviour:
|
I'm confused by the requested behaviour Currently, rbindlist is consistent with base R:
This issue requests that the expression columns be coerced to lists of expressions, but this only makes sense if all input data.tables have nrow=1. For example, if someone has a data.table with nrow > 1, then any expression column will have been defined using the base R behaviour illustrated above:
If we change the behaviour of rbindlist, what is the expected behaviour when binding this data.table? Should we keep the current behaviour, coercing to a composite expression, or put each element in a list as is the requested behaviour? |
After reading
And then we can also observe: vector("expression", 3)
#expression(NULL, NULL, NULL) Therefore it make sense to not wrap expression in extra list column, but process it as a vector, so |
Submitted by: Matt Dowle; Assigned to: Nobody; R-Forge link
From Jan Górecki on email :
The text was updated successfully, but these errors were encountered: