You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I will do the news release after 1.13.0 is released. Also, will update test tomorrow to make this pass.
library(data.table)
dt= data.table()
dt[, new:=1:5]
attr(dt, "row.names") ##fixed!#> [1] 1 2 3 4 5## warning for now - easy to change to error with feedback. ## data.table::groupingsets depended on this so there may be other issues with a hard changedt= data.table(x= integer())
dt[, new:=1:5]
## Warning message:## In `[.data.table`(dt, , `:=`(new, 1:5)) :## The data.table has 0 rows but there are 5 rows being assigned. The value will be ignored but new column(s) will be ## added. This warning will be upgraded to error in next releasedt#> Empty data.table (0 rows and 2 cols): x,new
@jangorecki let me know if I should split this up. The updating of row.names of data.table()[, new_var := 1:5] makes sense. However, I'm uncertain about data.table(x = integer())[, new_var := 1]. Current behavior is a zero-length variable being assigned. Proposed behavior is a warning with long-term aim of being an error. I did it as a single PR because they were relatively closely related.
Great fix, thanks.
As you alluded to above, and influenced by recent #4262, I went ahead and removed the new warning and reverted the changed tests. I'm (now) viewing data.table(x = integer())[, new_var := 1] as recycling of the length-1 to match the length-0 data. Happily, this is already what the tests tested, so my change to this PR brings that side of it back to current behavior so it can be merged to fix the row.names bug. Can always reconsider, discuss, and have another PR in future as you said.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4597.
I will do the news release after 1.13.0 is released. Also, will update test tomorrow to make this pass.