It is Time for CRAN to Ban Package Ads

NPM (a popular Javascript package repository) just banned package advertisements. I feel the CRAN repository should do the same.

Not all R-users are fully aware of package advertisements. But they clutter up work, interfere with reproducibility, and frankly are just wrong.

For example, here is the advertisement code from ggplot2:

.onAttach <- function(...) {
  withr::with_preserve_seed({
    if (!interactive() || stats::runif(1) > 0.1) return()

    tips <- c(
      "RStudio Community is a great place to get help: https://community.rstudio.com/c/tidyverse.",
      "Find out what's changed in ggplot2 at https://github.com/tidyverse/ggplot2/releases.",
      "Use suppressPackageStartupMessages() to eliminate package startup messages.",
      "Need help? Try Stackoverflow: https://stackoverflow.com/tags/ggplot2.",
      "Need help getting started? Try the cookbook for R: http://www.cookbook-r.com/Graphs/",
      "Want to understand how all the pieces fit together? See the R for Data Science book: http://r4ds.had.co.nz/"
    )

    tip <- sample(tips, 1)
    packageStartupMessage(paste(strwrap(tip), collapse = "\n"))
  })
}

The above means: when you attach ggplot2, it is needlessly monkeying with the pseudo-random number generator, and 10 percent of the time inserting an advertisement. This is needlessly non-deterministic and can spoil the production of a report if you don’t take the (advertised) precaution of using suppressPackageStartupMessages().

In R the correct way to attach a package should be:

library(PACKAGE_NAME)

and not:

suppressPackageStartupMessages(library(PACKAGE_NAME))

Users should insist on clean packages that can be attached deterministcly and neatly.

Tags: