Rdatatable / data.table

R's data.table package extends data.frame:
http://r-datatable.com
Mozilla Public License 2.0
3.62k stars 985 forks source link

Message when loading through R notebooks: "Registered S3 method overwritten by 'data.table':" #5103

Closed wlandau closed 3 years ago

wlandau commented 3 years ago

Sorry for posting an issue without content initially. I accidentally hit the wrong keystroke.

When I load data.table through the R console, I see the usual messages about threads etc., which is fine. But when I start a new session and load data.table through the R Markdown notebook interface in the RStudio IDE:

---
title: "R Notebook"
output:
  html_document:
    df_print: paged
---

```{r}
library(dtplyr)
```

I also see a message I would like to get rid of:

Registered S3 method overwritten by 'data.table':
  method           from
  print.data.table   

This message also appears if I restart R and load a package that imports data.table functions, such as dtplyr or targets. The unwanted S3 method message do not appear if I knit the notebook from end to end instead of clicking the right-hand green play button in the notebook interface.

Minimal reproducible example

Please see above.

Output of sessionInfo()

R version 4.1.0 (2021-05-18)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.7

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib

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] data.table_1.14.0

loaded via a namespace (and not attached):
[1] compiler_4.1.0 tools_4.1.0    knitr_1.33     xfun_0.24     
eddelbuettel commented 3 years ago

Is this not the same as a) using one many ways in knitr to suppress console output and/or b) doing what I do most of the time, wrapping suppressMessages(...) around one or more library(calls).

I was able to confirm that I did get the message (as you state) when not wrapped, but no longer see it once I wrap:

image

But I may well have misunderstood your issue or question.

TimTaylor commented 3 years ago

I think this might be an RStudio issue (see https://github.com/rstudio/rstudio/issues/9692). If you turn off diagnostics does that stop the problem? If it does would you mind giving a plus one on that issue and linking this.

wlandau commented 3 years ago

@TimTaylor, the message persists after I uncheck everything in global options -> code -> diagnostics. Likewise after I uncheck everything in global options -> code -> completion. But I went ahead and dropped a comment and thumbs up in that RStudio issue.

@eddelbuettel, the message does not bother me as a user, but it pops up for everyone using targets because of the dependency on data.table. I am starting to repeat myself when targets users ask me about it.

eddelbuettel commented 3 years ago

@wlandau There is nothing (AFAIK) that 'team data.table' can do for you here. That is base R, end of story.

You could recommend the following to your users which shadows how other people load dplyr where R also (rightly, I may add) yells at them for duplicated symbols:

image

TimTaylor commented 3 years ago

@eddelbuettel I think you are right that this is not for 'team data.table' but it is not what base R is doing that is the issue rather it is something Rstudio is doing .... to clarify if you take @wlandau's example Rmd and replace the call with library(data.table) you will get the same message which is somewhat cyclic:

Registered S3 method overwritten by 'data.table':
  method           from
  print.data.table 

@wlandau you can stop it happening by setting Chunk Output in Console - Screenshot from 2021-08-20 21-10-49

wlandau commented 3 years ago

Closing since this turned out to not be a data.table issue. Thanks for the input.

eddelbuettel commented 3 years ago

@TimTaylor I said so myself in https://github.com/Rdatatable/data.table/issues/5103#issuecomment-902371906 (see 1st and 2nd par). The issue has zero to do with RStudio.

TimTaylor commented 3 years ago

@eddelbuettel - we may have crossed wires but at least there is one less issue open. Perhaps semantics but I still think it is due to RStudio (but certainly could be wrong) as they override some s3 methods; see https://github.com/rstudio/rstudio/blob/edbc775214e1a46edd145ca6d37e14e2cded86e6/src/cpp/session/modules/NotebookData.R and https://github.com/rstudio/rstudio/pull/2762/files

eddelbuettel commented 3 years ago

@TimTaylor If you go back and read what I wrote then you may agree that it boils down to a) me saying you can suppress library loading noise by wrapping in suppressMessages(), and b) me saying you can suppress library noise by add adding warn.conflicts=FALSE (as well as c) telling knitr to be quiet, which is yet another layer). Neither has anything to with RStudio. (They may be at fault for tickling noise relative to dtplyr; that is outside of my realm as I d) mostly run R outside of RStudio and e) do not use that package all that much, and hence f) almost surely not inside RStudio.)

I.e. 'a page full of noise' on the left with plain library() calls, two quiet lines on the right.

image

I chimed in here in an attempt to be helpful to Will when nobody had yet answered his question. It was not my intend to upset or confuse you. If I have done so, my bad. Base R still works as instrumented when used as designed. That's really all I was trying to reaffirm. Peace out, and one issue down as you say.

TimTaylor commented 3 years ago

@eddelbuettel Zero upset or confusion caused - we are just looking at the issue differently. Enjoy the weekend.