Skip to content

assigning using := still prints while debugging via browser() #2319

@romunov

Description

@romunov

As per FAQ 2.21 and 2.22, printing of DT when using := has been suppressed since 1.8.3. However, I noticed that this still happens in borderline case, e.g. when debugging via browser(). Notice that this happens when one manually runs the assignment line, and not through pressing c, n or Enter. I can reproduce this in Rgui and RStudio (some nightly build).

I can confirm the same behavior in 1.10.5.

> library(data.table)
data.table 1.10.4
  The fastest way to learn (by data.table authors): https://www.datacamp.com/courses/data-analysis-the-data-table-way
  Documentation: ?data.table, example(data.table) and browseVignettes("data.table")
  Release notes, videos and slides: http://r-datatable.com
DT <- data.table(a = 1:3, b = letters[1:3])
DT[, c := rnorm(3)] # doesn't print object

# is browser() somehow responsible?
browser()
Called from: top level 
Browse[1]> DT[, d := rnorm(3)] # doesn't print object
Browse[1]> Q # doesn't appear so
 
sapply(1:3, function(x) {
  DT <- data.table(a = 1:3, b = letters[1:3])
  browser()
  DT[, e := rnorm(3)] # run this manually
})
Called from: FUN(X[[i]], ...)
Browse[1]> DT[, e := rnorm(3)] # prints object
   a b          c          d          e
1: 1 a -0.9089834 -0.8720443 -1.0034940
2: 2 b  1.2618214 -0.9993842  0.3317130
3: 3 c -2.2171694  0.2251432 -0.2082159

Behavior is consistent in lapply as well but not in a for loop.

for(i in 1:3) {
  DT <- data.table(a = 1:3, b = letters[1:3])
  browser()
  DT[, e := rnorm(3)]
}

Called from: top level 
Browse[1]> DT[, e := rnorm(3)] # doesn't print
Browse[1]> 

This is not big deal, I rather like it because I'm curious about my objects when debugging, just something I thought I'd let you know.

> sessionInfo()
R version 3.3.3 (2017-03-06)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

locale:
[1] LC_COLLATE=Slovenian_Slovenia.1250  LC_CTYPE=Slovenian_Slovenia.1250   
[3] LC_MONETARY=Slovenian_Slovenia.1250 LC_NUMERIC=C                       
[5] LC_TIME=Slovenian_Slovenia.1250    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] data.table_1.10.4

loaded via a namespace (and not attached):
[1] tools_3.3.3 yaml_2.1.14

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions