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

Varying behavior in print based on value of i #1150

Closed
rsaporta opened this issue May 14, 2015 · 2 comments
Closed

Varying behavior in print based on value of i #1150

rsaporta opened this issue May 14, 2015 · 2 comments

Comments

@rsaporta
Copy link
Contributor

When assigning :=, output is given if i has no matches, whereas output is suppressed if i does have a match.

eg:

set.seed(1)
DT <- data.table(A=1:3, Val=rnorm(3))
DT[ A < 3, Val := 0]  # Some rows matched, no output printed
DT[ A > 3, Val := 0]  # Zero rows matched, output was printed
#     A       Val
#  1: 1  0.000000
#  2: 2  0.000000
#  3: 3 -0.835629

related to #1122


It is worth noting that this could be useful when working interactively. EG, if the user is expecting to modify the DT and output is issued it serves as an indirect/subtle warning that there was no change to the table.

This being said, if we desire that behavior perhaps we should insert a check and proper warning.

@franknarf1
Copy link
Contributor

Related, regarding similar warnings for failure of := to make changes: #354

@mattdowle mattdowle added this to the v1.9.6 milestone Jun 19, 2015
@mattdowle
Copy link
Member

Already fixed. Item 2 on the v1.9.5 bug fix list. Checked tests were added to tests/autoprint.R in 84766f4

2 DT[FALSE,LHS:=RHS] no longer prints either, #887. Thanks to Jureiss for reporting.

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

No branches or pull requests

3 participants