Skip to content
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 #5580] invisible functions become visible in the j-expression #482

Closed
arunsrinivasan opened this issue Jun 8, 2014 · 8 comments
Closed

Comments

@arunsrinivasan
Copy link
Member

@arunsrinivasan arunsrinivasan commented Jun 8, 2014

Submitted by: Eduard Antonyan; Assigned to: Nobody; R-Forge link

fn = function() {invisible(1:5)}

dt[, fn()]
# [1] 1 2 3 4 5

This is pretty annoying when using e.g. boxplot.

@arunsrinivasan
Copy link
Member Author

@arunsrinivasan arunsrinivasan commented Aug 3, 2014

@eantonya could you provide an example usage with boxplot?

The problem here is very much related to :=, as explained in FAQ 2.22.

The best we can do is to return invisibly iff fn() returns a data.table. Else, we'll have to modify all the print methods the same way how print.data.table does cleverly using .global$print.

I've added the label 'won't fix' for now. As it's a problem with the way base R forces visibility on [. If you agree, we can close this as such (unless there's an alternative we can come up with).

Tagging @mattdowle as well.

@MichaelChirico
Copy link
Member

@MichaelChirico MichaelChirico commented Jan 9, 2016

I think this may be identical to #1471. Just found this.

@MichaelChirico
Copy link
Member

@MichaelChirico MichaelChirico commented Feb 7, 2016

It's too bad R doesn't return something with an "invisible" attribute when it is the result of invisible. That would make this easy.

@mattdowle
Copy link
Member

@mattdowle mattdowle commented Mar 18, 2016

Linking back to http://stackoverflow.com/a/36093766/403310 which links here. We could revisit FAQ 2.18 (the solution there didn't work for me when I just tested it) as well as 2.22 and over a year has passed since we last looked so another attempt may be due.

@MichaelChirico
Copy link
Member

@MichaelChirico MichaelChirico commented May 12, 2016

Hmm. Just noticed that with(dt, fn()) doesn't print the output. I guess this is related to the whole .global$print issue more than anything, then.

@arunsrinivasan
Copy link
Member Author

@arunsrinivasan arunsrinivasan commented May 12, 2016

No it is because R internally forces visibility on [ unlike with(). See FAQ 2.22.

@eantonya
Copy link
Contributor

@eantonya eantonya commented Jun 13, 2016

Can't the same global print suppression that works with := work here?

@jangorecki
Copy link
Member

@jangorecki jangorecki commented Jun 3, 2019

as per Arun comment, we cannot do much about R's [ forcing visibility, solution is to wrap your data.table expression into invisible.

@jangorecki jangorecki closed this Jun 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants