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

Recognizing and suppressing invisible output to j #1471

Closed
MichaelChirico opened this issue Dec 17, 2015 · 1 comment
Closed

Recognizing and suppressing invisible output to j #1471

MichaelChirico opened this issue Dec 17, 2015 · 1 comment

Comments

@MichaelChirico
Copy link
Member

This is derived from this topic on SO. Here's the example:

set.seed(120834)
DT <- data.table(var = rnorm(100))

The following returns the hist object invisibly (as can be readily seen from hist.default code):

hist(DT[ , var])

However, when hist is called within j (which feels more natural to me), it appears the hist object is returned invisibly within j, then j returns visibly:

DT[ , hist(var)]
$breaks
 [1] -3.0 -2.5 -2.0 -1.5 -1.0 -0.5  0.0  0.5  1.0  1.5  2.0  2.5

$counts
 [1]  1  1  6  7 16 20 20 12 12  3  2

$density
 [1] 0.02 0.02 0.12 0.14 0.32 0.40 0.40 0.24 0.24 0.06 0.04

$mids
 [1] -2.75 -2.25 -1.75 -1.25 -0.75 -0.25  0.25  0.75  1.25  1.75  2.25

$xname
[1] "var"

$equidist
[1] TRUE

attr(,"class")
[1] "histogram"

However, I noticed that this is not an issue for with, which, if I'm understanding correctly, should be going through the same procedure: with(DT, hist(var)) returns the hist object invisibly.

Is there any way to get j to recognize when it's been returned an object invisibly and to pass this through to the console? The alternative (always suppressing j output) is too blunt a tool.

@MichaelChirico
Copy link
Member Author

Closing as identical to #482.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant