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

prints complete table with data.table when update by reference #10

Open
ghost opened this issue Sep 10, 2015 · 6 comments
Open

prints complete table with data.table when update by reference #10

ghost opened this issue Sep 10, 2015 · 6 comments

Comments

@ghost
Copy link

ghost commented Sep 10, 2015


---
title: "copy this into a Rmd"
author: "Henk Harmsen"
date: "September 10, 2015"
output: html_document

---

```{r}
library(data.table)

data(mtcars)
df = data.table(mtcars)
```

this works, no intention to print/head table:

```{r}
df[, mpg2 := mpg * 2]
```

but after loading printr, update by reference prints out the whole table:

```{r}
library(printr)
df[, mpg3 := mpg2 / 2]
```
@yihui
Copy link
Owner

yihui commented Sep 10, 2015

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

@ghost
Copy link
Author

ghost commented Sep 11, 2015

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:
Rdatatable/data.table#1326

@yihui
Copy link
Owner

yihui commented Sep 11, 2015

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.

@m-dz
Copy link

m-dz commented Apr 21, 2016

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)
```

```{r chunk}
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

@yihui
Copy link
Owner

yihui commented Apr 21, 2016

Thanks for the report. I don't understand the data.table printing magic, and I guess we will need the help from Matt Dowle.

@m-dz
Copy link

m-dz commented Apr 22, 2016

It looks like something related to this commit in data.table.

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

2 participants