Open ghost opened 8 years ago
For some reason, the table is still printed even before printr is loaded when I tried your example. My session info:
> library(data.table)
data.table 1.9.4 For help type: ?data.table
*** NB: by=.EACHI is now explicit. See README to restore previous behaviour.
> library(knitr)
> sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: x86_64-apple-darwin14.5.0 (64-bit)
Running under: OS X 10.10.5 (Yosemite)
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] knitr_1.11.1 data.table_1.9.4
loaded via a namespace (and not attached):
[1] magrittr_1.5 plyr_1.8.3 rsconnect_0.4.1.4 htmltools_0.2.9
[5] tools_3.2.2 reshape2_1.4.1 yaml_2.1.13 Rcpp_0.12.1
[9] stringi_0.5-5 rmarkdown_0.8 stringr_1.0.0 digest_0.6.8
[13] chron_2.3-47
A similar question has been asked before: http://stackoverflow.com/q/15267018/559676
the stackoverflow post refers to knitr, apparently in combination with data.table 1.9.4. the table print problem does not occur in knitr / data.table 1.9.5 [that's why you couldn't reproduce my output [sorry for not including sessionInfo()]].
however, now the problem seems to be the printr / data.table 1.9.5 combination. I have posted the issue at data.table: https://github.com/Rdatatable/data.table/issues/1326
Right. data.table 1.9.5 is not on CRAN, and you didn't mention your session info, so I missed it.
Similarly, I guess the data.table author will be confused if you don't point out where you got the printr package.
Just to let you know, the issue is still open with data.table 1.9.6 (on CRAN).
---
title: "test"
output:
html_document
---
```{r load data}
library(printr)
library(data.table)
mtcarsDT <- data.table(mtcars)
mtcarsDT[, gear := factor(gear)]
sessionInfo():
R version 3.2.5 (2016-04-14)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=English_United Kingdom.1252
[2] LC_CTYPE=English_United Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] data.table_1.9.6 printr_0.0.5
loaded via a namespace (and not attached):
[1] magrittr_1.5 formatR_1.3 tools_3.2.5 htmltools_0.3.5
[5] yaml_2.1.13 Rcpp_0.12.4 stringi_1.0-1 rmarkdown_0.9.5
[9] knitr_1.12.3 stringr_1.0.0 digest_0.6.9 chron_2.3-47
[13] evaluate_0.8.3
Thanks for the report. I don't understand the data.table printing magic, and I guess we will need the help from Matt Dowle.
It looks like something related to this commit in data.table.
this works, no intention to print/head table:
but after loading printr, update by reference prints out the whole table: