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

[bug] Printing error when assigning to table nested in structure #1758

Closed
fruce-ki opened this issue Jun 28, 2016 · 0 comments
Closed

[bug] Printing error when assigning to table nested in structure #1758

fruce-ki opened this issue Jun 28, 2016 · 0 comments
Labels
Milestone

Comments

@fruce-ki
Copy link

Following discussion on StackOverflow ([http://stackoverflow.com/questions/38016170/getting-a-printing-error-while-assigning-vector-to-data-table-column/38073502#38073502]) I seem to have encountered a bug. This occurs when assigning to a pre-allocated table column.

Error message:

Error in SYS[[length(SYS) - 3L]][[1L]] == "knit_print.default" : 
  comparison (1) is possible only for atomic and list types

The code does not crash and the error is not printed to the console until I attempt to display the value of the table or of its containing structure. The error occurs only when the assignment is executed from source code. If I interrupt the execution and paste the offending assignment into the console, it executes without problem.

Searching the internet for the error, I found literally nothing, except for the source code of data.table here on github. The relevant code is in lines 45-50, and seems to regard supressing knitr print output for in-place assignments.

The error still exists in the latest dev version of data.tables from github.

Minimal reproducible example:

alloc_out <- function(annot = c("a", "b")) {
  Genes <- data.table("parent" = annot, flag = NA)
  ro <- structure(list("Genes" = Genes), class=c("dtu"))  # This sets up the error.
#  ro <- structure(list("Genes" = Genes))  # This alternative does not lead to the error.
  ro$Genes[, flag := TRUE]  # This causes error in source, but works in console.
  return(ro)
}

The error seems to be triggered by the line encapsulating the table into a strucutre. Specifically my use of a class attribute. Omitting the class attribute, leads to no error.

Session info:

R version 3.2.4 (2016-03-10)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11.5 (El Capitan)

locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8

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

other attached packages:
[1] rats_0.1         data.table_1.9.6

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.4        matrixStats_0.50.2 digest_0.6.9       withr_1.0.1        chron_2.3-47       jsonlite_0.9.19    magrittr_1.5       stringi_1.0-1      devtools_1.11.0    tools_3.2.4        stringr_1.0.0      htmlwidgets_0.6    yaml_2.1.13       
[14] parallel_3.2.4     memoise_1.0.0      htmltools_0.3.5  

(rats_0.1 is my package in development, where this bug became apparent)

@arunsrinivasan arunsrinivasan added this to the v1.9.8 milestone Jul 1, 2016
jangorecki added a commit to jangorecki/data.table that referenced this issue Jul 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants