Thanks for the bug reports, everyone. It looks like this is an IDE issue (we're running afoul of some changes in S3 dispatch behavior in R 3.5.0). I've filed an issue here:
opened 08:41PM - 05 May 18 UTC
closed 11:22PM - 09 May 18 UTC
bug
### System details
RStudio Edition : Desktop
RStudio Version : v1.2.… 602
OS Version : macOS 10.13.4
R Version : 3.5.0
### Steps to reproduce the problem
Try running the following chunk in an R Notebook:
```R
library(tibble)
as_tibble(mtcars)
```
### Describe the problem in detail
The table is printed as 'plain' `tibble` output, rather than as a paged table.
### Describe the behavior you expected
This should be printed as a paged table.
### Diagnosis
From https://github.com/rstudio/rmarkdown/issues/1331:
Something appears to be going awry with S3 dispatch in the Notebook context. One can see the issue by attempting to debug the `print` call in a Notebook chunk, using R 3.5.0 with RStudio v1.2:
`````
```{r}
debugonce(print)
as_tibble(mtcars)
```
`````
When running this, I see:
```R
> debugonce(print)
> as_tibble(mtcars)
debugging in: function (x, ...)
UseMethod("print")(x)
debug: UseMethod("print")
Browse[2]> class(x)
[1] "tbl_df" "tbl" "data.frame"
Browse[2]> print.tbl_df
function (x, ...)
{
o <- overrideMap(x, options)
if (!is.null(o)) {
overridePrint(o$x, o$options, o$className, o$nRow, o$nCol)
}
}
<bytecode: 0x7fad5be20ec0>
<environment: 0x7fad44a37498>
```
So it appears like the S3 override we've registered should be in scope for this print call. However, this is not the case -- the S3 method registered in `tibble` is called instead.
```R
Browse[2]> s
debugging in: print.tbl_df(x)
debug: {
cat_line(format(x, ..., n = n, width = width, n_extra = n_extra))
invisible(x)
}
```
The [NEWS](https://cran.r-project.org/doc/manuals/r-release/NEWS.html) file of R 3.5.0 has this:
> - S3 method lookup now searches the namespace registry after the top level environment of the calling environment.
So it seems like R has explicitly switched up the mechanism used for S3 dispatch, and this has broken the way we override the S3 methods when injecting our own printers. We'll have to think about how to accommodate this change in behavior.
and we'll try to find a fix soon.
3 Likes