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

tests/knitr.R mismatch #6509

Open
jangorecki opened this issue Sep 20, 2024 · 4 comments
Open

tests/knitr.R mismatch #6509

jangorecki opened this issue Sep 20, 2024 · 4 comments
Labels
Milestone

Comments

@jangorecki
Copy link
Member

jangorecki commented Sep 20, 2024

reported on CRAN now. https://cran.r-project.org/web/checks/check_results_data.table.html
none of the commits mentioned in 1.16.2 issue seems to be providing the fix, so likely the issue is still there (fyi @TysonStanley )

    Comparing ‘knitr.Rout’ to ‘knitr.Rout.save’ ...28,38d27
  < ```
  < 
  < ```
  < ##        x     y     z
  < ##    <int> <int> <int>
  < ## 1:     1     4     7
  < ## 2:     2     5     8
  < ## 3:     3     6     9
  < ```
  < 
  < ``` r
  52,62d40
  < ```
  < 
  < ```
  < ##        x     y     z     a
  < ##    <int> <int> <int> <int>
  < ## 1:     1     4    10     1
  < ## 2:     2     5    11     1
  < ## 3:     3     6    12     1
  < ```
  < 
  < ``` r
@MichaelChirico
Copy link
Member

Copying @TysonStanley 's comment here:

Looks like the difference is that DT[, z := 7:9] is printing in the knitr output.

  < ##        x     y     z
  < ##    <int> <int> <int>
  < ## 1:     1     4     7
  < ## 2:     2     5     8
  < ## 3:     3     6     9

@MichaelChirico
Copy link
Member

Copying Tyson's next comment here too:

Not sure why it's not showing up in CI checks at all. It's a note on Linux and windows on CRAN and it showed up on MacOS for me here.

@MichaelChirico
Copy link
Member

I'm not reproducing it locally, and we don't see it on GHA nor on GitLab CI logs. Makes it a lot tougher to debug.

@TysonStanley, can you confirm your R, knitr and data.table versions where you're seeing the issue? And maybe try doing trace(data.table:::shouldPrint, at=3, quote(message("ret=", ret))) and check the output of the knitr test again?

@TysonStanley
Copy link
Member

Only happens when I'm accessing R directly in the terminal but this is what happened when I inserted that code into the .Rmd before knitting:

``` r
require(data.table)              # print?
trace(data.table:::shouldPrint, at=3, quote(message("ret=", ret)))
```

```
## [1] "shouldPrint"
```

``` r
DT = data.table(x=1:3, y=4:6)    # no
DT                               # yes
```

```
## Tracing shouldPrint(x) step 3
```

```
##        x     y
##    <int> <int>
## 1:     1     4
## 2:     2     5
## 3:     3     6
```

``` r
DT[, z := 7:9]                   # no
```

```
## Tracing shouldPrint(x) step 3
```

```
##        x     y     z
##    <int> <int> <int>
## 1:     1     4     7
## 2:     2     5     8
## 3:     3     6     9
```

``` r
print(DT[, z := 10:12])          # yes
```

```
## Tracing shouldPrint(x) step 3
```

```
##        x     y     z
##    <int> <int> <int>
## 1:     1     4    10
## 2:     2     5    11
## 3:     3     6    12
```

``` r
if (1 < 2) DT[, a := 1L]         # no
```

```
## Tracing shouldPrint(x) step 3
```

```
##        x     y     z     a
##    <int> <int> <int> <int>
## 1:     1     4    10     1
## 2:     2     5    11     1
## 3:     3     6    12     1
```

``` r
DT                               # yes
```

```
## Tracing shouldPrint(x) step 3
```

```
##        x     y     z     a
##    <int> <int> <int> <int>
## 1:     1     4    10     1
## 2:     2     5    11     1
## 3:     3     6    12     1
```
Some text.

The DT[, z := 10:12] definitely triggers shouldPrint(x). Is there more information I can extract? Should I set verbose = TRUE for these as well?

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

3 participants