-
Notifications
You must be signed in to change notification settings - Fork 997
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
An empty DT()
doesn't print at the end of a pipe chain
#5106
Comments
Thanks for testing! Yes agree on I guess you mean
otherwise method dispatch would mean |
I've changed |
@mattdowle thank you for all your effort!
If always printing the output when returning to REPL is really needed, a good compromise could be to make it optional |
@Kamgang-B it doesn't always print. By "always prints when it's returned to the REPL" that means when the last value in a chain is returned to the REPL then it always prints. As opposed to the last value not printing when that last expression is a Also, in my mind currently, consistency with the classical data.table chaining, is not a goal of DT() per se. What is a goal is that DT() should behave however users want it to behave; the way that is most useful in most cases. Over the years, data.table has suffered in some areas because consistency-with-whatever has been seen as top priority, even when nobody agreed with the behavior that we were being consistent with. If there is no reason to be inconsistent, then sure, let's be consistent. For example, changing |
Hi @mattdowle. About my point 1:
The idea was that when these chunks are sequentially dependent, then we would run all the chunks at the same time but would very likely be interested only in the output of the last chunk. And printing the output of the first two chunks would likely be less desired than adding an extra About how users would like
I know that in (b), reassigning would also prevent printing but it would not be useful since the assignment is done by reference. Thinking in terms of new users:
Altought I can't find a link to some examples now, I remember that I read several times some people comments about the fact that they find the reassignment as it is done in the (d) when working with dplyr annoying (although they still preferred dplyr's piping style over square brackets). For this category of people, assigning by reference when using a data.frame would likely be preferred (and me too I don't like the reassignment but think that it is safe for users that are not used to the data.table approach). |
Thanks. Still mulling everything over and rereading. |
Thanks @mattdowle Another option could be to add an additional argument ( I feel like if this part of the discussion about the assignment/modification is more related to #5129 than this issue. |
Yes good points. Just a quick thought to add is that since data.frame are not over-allocated, they have to be shallow copied anyway to be able to add a new column. There is just no way around that. So at best there'd be a difference in DT(,:=) between whether it is updating existing columns (that could be by reference as happens currently in dev) and adding new columns which couldn't be by reference. Whereas a data.table can be updated by reference consistently w.r.t. updating existing columns vs adding new columns. Caveat when the over allocation is used up. |
Hi @mattdowle Hope you are fine. This is more a feature request related to the use of While discussing with some colleagues about the new function
This feature can be created by adding all the formal arguments (with their default values) from
|
Code from first post is now printing as expected, but it also gives a warning, likely unexpected copy(test_df) |>
DT(, double_x := x * 2) |>
DT()
# x y double_x
# <int> <int> <num>
#1: 1 1 2
#2: 2 2 4
#3: 3 3 6
#Warning message:
#i and j are both missing so ignoring the other arguments. This warning will be upgraded to error in future. |
I was testing out the new
DT()
function and was expecting it to cause printing much like the equivalent[.data.table
syntax.Edit: One option would be to define
DT()
as:The text was updated successfully, but these errors were encountered: