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

No realloc warning when adding many columns in a loop, inside a function #1633

Open
mattdowle opened this issue Apr 6, 2016 · 0 comments
Open

Comments

@mattdowle
Copy link
Member

> packageVersion("data.table")
[1] ‘1.9.7’
> x = data.table(a=1:3)
> truelength(x)
[1] 100
> f = function(DT) {
+  for (i in 1:200) {
+    DT[,paste0("new",i):=1:3]
+  }
+ }
> f(x)            # I thought there was a warning here that := on i==100 did a realloc
> dim(x)
[1]   3 100       # wrong result
> f = function(DT) {
+  for (i in 1:200) {
+    DT[,paste0("new",i):=1:3]
+  }
+  DT                            # needed in this case
+ }
> x = f(x)                       # x= needed in this case
> dim(x)
[1]   3 201                      # correct result

I seem to remember there was a warning. Maybe it isn't happening in this case for some reason. Need to reinstate the warning and add a test for it.

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