-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Print method for subclass makes :=
return visible output
#3029
Comments
@mattdowle I don't quite get what all is meant to be covered here:
First thing that comes to mind is to look for |
We're seeing a similar issue in our R scoringutils. Is there any solution or steps we could take? Thank you! |
I don't think that expanding |
Still feels pretty clunky to me -- does that distinguish explicit edit: no, it won't, c.f.:
It looks like the key to detecting the autoprint is this esoteric first entry in the call stack: sys.calls()
# [[1]]
# (function (x, ...)
# UseMethod("print"))(x)
# ...rest of stack... That's just the substitute(f(x), list(f = print))
# (function (x, ...)
# UseMethod("print"))(x)
identical(sys.calls()[[1]][[1]], print)
# [1] TRUE That sys.calls()
# [[1]]
# print(dt)
# [[2]]
# print.data.table(dt) Another idea is to add an argument to |
Hmm, is it considered intentional behavior that print(as.data.table(mtcars)[,y:=2]) Does not print anything? I would guess no? |
|
The idea in #6631 is that what R does in order to auto-print |
I'm extending
data.table
class and I'm having a problem. When defining a custom print method operations with:=
print the object instead of returning it invisibly.(The output doesn't seem to appear when reprexed, but it's there in interactive mode, please test)
I don't know what I'm doing wrong and I cannot find much documentation on this.
The text was updated successfully, but these errors were encountered: