Menu Home

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.

Here is an example which could be considered to contain advertisements: .onAttach() from ggplot2 (promoting websites, and books):

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

    tips <- c(
      "RStudio Community is a great place to get help:",
      "Find out what's changed in ggplot2 at",
      "Use suppressPackageStartupMessages() to eliminate package startup messages.",
      "Need help? Try Stackoverflow:",
      "Need help getting started? Try the cookbook for R:",
      "Want to understand how all the pieces fit together? See the R for Data Science book:"

    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 (in addition to running it is attempting to re-wind its state to appear to not have run it), and 10 percent of the time inserting an advertisement. This is needlessly non-deterministic and can spoil work if you don’t take the (advertised) precaution of using suppressPackageStartupMessages().

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


and not:


This specific instance may or may not bother you. But if this style of messaging is allowed, what advertising is also allowed and where will that take us?

Users should insist on clean packages that can be attached deterministically and neatly. Users should insist on having access to “free software“, (“advertising supported” is often not considered the same as “free”).

Categories: Opinion

Tagged as:


Data Scientist and trainer at Win Vector LLC. One of the authors of Practical Data Science with R.

9 replies

    1. First thanks for your polite reply.

      I would say if we are going to have ads we would need community standards or rules as to what is acceptable. Though in my opinion, I’d rather not have ads at all in my software. In the above example the messages include some help links (but: if the message is important enough to show, it then it is important enough to show all the time). But the messaging also currently includes:

      Two books for sale (though I do think these have have free online copies available).
      Promotion of the RStudio Community, a community run by RStudio for both answer questions and promoting the RStudio company and products (much like this blog promotes Win Vector LLC).

      I wouldn’t mind such text in the project documentation, announcements, or web-sites. But in my opinion it crosses the line to have it in .onAttach().

      1. Obviously it’s subjective but, to me, it feels quite harsh to see the tips as doing anything other than offering help to the users. The r4ds website is clear that it’s a free version that’s the same as (probably even more up to date than) the book available to purchase. Promoting the rstudio community again feels like it helps the user, similar to the stackoverflow suggestion. As I said, it’s subjective and so perhaps a helpful way of setting an option to not run the messages might a better alternative to suppressMessages?

      2. I get it.

        But subjectively to me, it only appears to be neutral help. It doesn’t say things like “want faster results, try data.table?”, “interested in graphing, try the R Graphics task view?” It has some neutral links to stack-overflow, and some cliquish links.

  1. It would seem you are arguing to restrict free speech for free software. I don’t like it but package authors put a lot of work into writing them. What’s your thought on startup messages that request a citation if used? Isn’t that also advertising?

    1. R has package startup messages as part of the language. So one should expect there may be messages. I have seen good uses of them warning about name collisions and sub-packages or assemblies not being correctly configured. That is probably close to the intended use.

      Probably requesting a citation is at a different place than asking to join a forum for a lot of people.

  2. On balance, I’m inclined to agree. There is a huge body of packages that users have contributed for no reward other than seeing their work achieve greater use and, if appropriate, a citation.

    There is always a temptation for commercial organisations to exploit successful open-source software and it’s important to avoid this damaging the underlying product. That’s not to say that commercial input is always harmful. Rstudio have made a very helpful contribution – I use it often – but I would not support the introduction of code and other run-time resources to promote commercial interests.

    Perhaps CRAN could incorporate this into their package guidelines and Acceptance Tests. A possible compromise might be to permit a message when a package is loaded but not each time the Library is initialised.

  3. I think it’s a fair point, although I don’t agree. Perhaps if there was a way to block these messages from appearing?
    For me personally, I think that if somebody has taken the time to build an open-source piece of software, they should be able to advertise what they want with it — when it loads, on the GitHub/Lab etc repo, on any websites and so on. I can see how it can be a little annoying, but the alternative quasi-authoritarianism is not appealing.

    1. One of the goals of ideals behind free software is letting users decide what their computer does. I find it hard to image any user wants these kind of messages. Because the packages are open source, it’s possible for anyone to just remove the advertising code and rebuild the package. But I’d prefer CRAN just set out a “no ads during runtime” rule.

      And, just to make sure we’re not picking on the Tidyverse alone, data.table prints unnecessary advice on load.

%d bloggers like this: