58

I'm struggling to create a reproducible example for this, but I suspect others will know what I mean. Why does R sometimes seem to get stuck with a backlog of warnings/error messages that it repeats again after subsequent commands? E.g. you get some warning message Bad whatever system choking after running some code, which repeats again after you enter an innocuous instruction like x <- 5. This sometimes happens after several entries of x <- 5, although it normally stops after one or two.

R has been like this for me for at least 5 years, across many versions on both Windows and Mac. Am I alone? Does anyone know if it has been identified as a bug? I normally work with RStudio so I wonder if it's related to the IDE.


Edit. Pretty sure this is related to RStudio.

geotheory
  • 22,624
  • 29
  • 119
  • 196
  • it happens to me too, sometimes. As I work only with RStudio like you do, I don't know whether it is related to R or to this IDE. Try rerunning your code in R (with no RStudio). – Davide Passaretti Mar 17 '17 at 18:16
  • 2
    Possibly related: When writing a complex function sometimes RStudio's auto complete will get a syntax error mixed in when it tries to examine objects and generate a huge stream of errors. I don't think this is quite what you are seeing. – Bishops_Guest Mar 17 '17 at 18:29
  • 6
    I see this pretty regularly. I suspect it's an artifact of a speed mismatch in how error handling is built into the REPL, but that's speculation. I'm sure someone on r-devel could tell you why, but they're a group best approached with caution and a solid knowledge of R's internals. Maybe find a reprex and ask on r-help first. – alistaire Mar 17 '17 at 18:45
  • 3
    @alistaire `a group best approached with caution` made me chortle – geotheory Mar 17 '17 at 18:56
  • 1
    Useful: `assign("last.warning", NULL, envir = baseenv())` – geotheory Jun 07 '17 at 16:59
  • 3
    using `assign("last.warning", NULL, envir = baseenv())` does not fix the problem for me, because it keeps coming back. What solved the issue was to do a `rm(list=ls())`, restart the session and do everything again step by step. I did not find the command that gave the warnings doing this, so it was probably something that I corrected along the way, but at least it stopped. One more reason to always be sourcing everything instead of saving in .Rdata – RBA Jun 21 '17 at 09:11
  • You're right - if it works it's a temporary effect – geotheory Jun 21 '17 at 17:39
  • 1
    Late in the game here, but I do *not* see this behavior in emacs/ess, supporting your suspicion that it is related to RStudio. (I've been using emacs/ess for ~6 years). – r2evans Jan 19 '18 at 17:52
  • And 5 months later now we are on to a new RStudio `1.1.447` and the problem still persists. It is annoying when you are wanting to focus on the debugging steps and lo.. a flurry of warning messages start pouring in that are unrelated to the current line. Has anyone posted this on the rstudio support? Now they have a brand new support portal. – Lazarus Thurston May 11 '18 at 18:25
  • I have posted a possible reason (and solution) [here](https://stackoverflow.com/a/56309857/6879233) – JASC May 26 '19 at 00:59
  • If it is temporary, I ask: ave you tried to empty the enviroment? I On the terminal type: `rm(list=ls())`. I assume you have your scripts saved. For more insight on this, refer to Hadley's book: https://r4ds.had.co.nz/workflow-projects.html – BMLopes Jul 19 '21 at 02:07
  • This might be a [reproducible example](https://stackoverflow.com/questions/66982681/how-to-suppress-warnings-with-ggrepel). – Waldi Sep 20 '21 at 18:09
  • Does this answer your question? [Fixing a multiple warning "unknown column"](https://stackoverflow.com/questions/39041115/fixing-a-multiple-warning-unknown-column) – Artem Feb 02 '22 at 21:38

1 Answers1

1

Answer by zeehio.

This is an issue with the Diagnostics tool in RStudio (the tool that shows warnings and possible mistakes in your code). It was partially fixed at this commit in RStudio v1.1.103 or later by @kevin-ushey. That fix was partial, because the warnings still appeared (albeit with less frequency). This issue was reported with a reproducible example at https://github.com/rstudio/rstudio/issues/7372 and it was fixed on RStudio v1.4 pull request.

The warnings appear because the diagnostics tool in RStudio parses the source code to detect errors and when it performs the diagnostic checks it accesses columns in your tibble that are not initialized, giving the Warning we see. The warnings do not appear because you run unrelated things, they appear when the RStudio diagnostics are executed (when a file is saved, then modified, when you run something...).

Artem
  • 3,304
  • 3
  • 18
  • 41