-
-
Notifications
You must be signed in to change notification settings - Fork 878
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
Feature request: a way to easily suppress package startup messages #1583
Comments
These are often unwanted in knitr output, so this allows control of whether to display them or not Fixes yihui/knitr#1583
These are often unwanted in knitr output, so we default to not showing them. Requires a corresponding change to evaluate r-lib/evaluate#86 Fixes yihui#1583
There is nothing wrong with @jimhester's (thanks!) implementations (#1584 r-lib/evaluate#86). In practice, you would have to set the option in every document: knitr::opts_chunk$set(package.startup.message = FALSE) I don't feel this is convenient enough for your case. Given the complexity of the two PRs (although they are not really complex), I'd rather use your wrapper function of I wish base R could provide such a global option. Usually I don't like package startup messages, either. |
I hope you'll reconsider the PR... I agree that One way to simplify it is to suppress package startup messages by default. I think that that would be the desired behavior in the vast majority of cases. I could understand, though, if you are reluctant to do this because it is a significant change in behavior. I don't think |
xfun is already a dependency of knitr. This question has been asked multiple times on SO: https://www.google.com/search?q=knitr+suppress+package+startup+message (I answered one of them, and I guess that was my most upvoted answer on SO). Yes,
So the cost of the approach Jim proposed is two pull requests in two packages, plus documentation (in two packages), plus this in every document: knitr::opts_chunk$set(package.startup.message = FALSE) The cost of the wrapper library <- function(...) suppressPackageStartupMessages(base::library(...)) is only the wrapper function (in every document). And the function is simple enough. If you are concerned about the strangeness of Anyway, I'm not convinced that knitr is the right place to solve the problem. If this problem is only solved in knitr, users may be surprised that when they run the code in the console (or R Markdown Notebooks) and see the messages. That is why I recommend a feature request to base R to suppress package startup messages. If you suppress them, it may be a better idea to do it consistently. If you really hate the messages of a particular package, you may consider a feature request to that particular package :) Of all possible ways to go, my personal preference is to attach packages in a separate code chunk with
This is certainly not a reliable solution (e.g., what if a package no longer emits messages). Typically I try my best not to close PRs, but for this one, I really don't think the gain is significant compared to the cost. |
My knitr PR set the option to default to
This is what I do as well, but many people clearly don't realize you can do this. E.g. there are > 500 people with .md files containing the tidyverse attach message on GitHub. I would wager the vast majority of those people would prefer not to have this message in their output, but don't know how to suppress it. |
I don't really know whether defaulting to It is hard to know whether these 500 people don't know how to suppress messages (they could easily find it out if they could google) or just don't bother. Winston is the first person who has proposed that package startup messages should be suppressed by default in the seven years of knitr. Is tidyverse the only or primary source of pain? If it is, I'd ask Hadley not to print the message in non- Seriously, I'm willing to pay each of you $100 not to introduce this new option in knitr or evaluate. The workaround is simple enough. I don't want to maintain the new code or documentation, or make the decision on whether this option should default to Thanks again! |
…forms (not only Windows), since Microsoft's R could also fail with the 'auto' method in download.file() Daijiang Li (1): add test_string for n2w() (#6) Xianying Tan (2): is_ascii() returns NA for NA_character_ (#9) invalid_utf8() should ignore NA input (#10) Yihui Xie (16): replace random tempdir/tempfile paths in check logs to avoid diffs when comparing check logs support the class JS_EVAL in tojson() mention jsonlite move the argument rw_error from gsub_dir() to gsub_file() canonical CRAN URL close rstudio/rmarkdown#708 and close rstudio/blogdown#106: provide a simple yet general approach to embedding files/dir in HTML output roxygenize and bump version enable code coverage add some sample tests install covr earlier update roxygen close yihui/knitr#1583: add a `message` argument to pkg_attach() so that we can suppress package startup messages fix rstudio/blogdown#327: try all methods on all platforms (not only Windows), since Microsoft's R could also fail with the 'auto' method in download.file() stop if zip() fails mention that the download link doesn't work with IE CRAN release v0.4
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary. |
In my Rmd documents, I almost never want something like
library(tidyverse)
to print out package startup messages. However, using themessage=FALSE
chunk option can be a little problematic, for two reasons: first, you have to think about it and do it; second, it may suppress other messages that are actually useful.One possible workaround is for the user to put this in an
echo=FALSE
orinclude=FALSE
chunk:The user still has to remember to do it, though, and it's non-trivial for most people to write that code. Also, it won't catch
library()
calls that are from outside code.In a conversation elsewhere, @jimhester suggested adding a
packageStartupMessage
chunk option which defaults toFALSE
, and I agree that this would be a good idea. The evaluate package would need to support this.The text was updated successfully, but these errors were encountered: