Suppress startup message of dependency

I am pretty new to package development, and I am currently struggling with a rather silly issue. My package ("ggseqplot") has one dependency ("TraMineR") which displays its startup message (created with packageStartupMessage) every time my package is loaded. I have my own startup message, however, which also acknowledges the dependency and I want to get rid of the startup message of the dependency.

I assume that this has to happen within the .onAttachcall in "zzz.R". I tried a bunch of different solutions suggested on StackExchange, but I didn't succeed in getting rid of the dependency's startup message. I am very much looking forward to your suggestions for solving my little newbie problem.

1 Like

No silly issue / little newbie problem :wink:

Just to be sure, why is TraMineR listed in Depends as opposed to Imports? If it were Imports, its startup messages would automatically be removed.

Then, from reading R suppress startupMessages from dependency - Stack Overflow and from tests with a local example package I am under the impression that you can either

  • use Imports instead of Depends,
  • use Suggests instead of Depends AND loading the TraMineR package in .onLoad(). You would also need some safeguards in tests as CRAN sometimes run tests without installing Suggested packages. By safeguards I mean something like a custom skipper that'd skip tests based on whether TraMineR is installed, see Skipping tests • testthat

Maybe someone else here will have other ideas though!

I started wondering whether TraMineR code could be amended to make the message conditional based on where it is attached from but I can't think of a solution. :sweat_smile:

Lastly here are some recommendations for making one's package easier to cite, that are not startup messages: rOpenSci | Make Your R Package Easier to Cite :smiley_cat:

1 Like

Thanks for your response and the helpful link to the citation blog post. I added TraMineR as a dependency because my package is "designed to be used in conjunction with [this] package" which according to Wickham & Bryan seems to be the only legit case for a dependency. As all of my examples in the documentation and all tests are using example data from TraMineR and also call functions from TraMineR it seemed reasonable to reflect this very close "conjunction" by making it a dependency. Nevertheless, I will think about reverting to an Import.

I am really surprised that it is not as easy as I expected to get rid of the starting message. Maybe, that's due to the fact that starting messages are not commonly used and that dependencies are rarely used these days.

Note that if you revert to Suggests, and load the TraMineR package in your package's .onLoad(), you more or less mimick the behavior of Depends (minus the startup message, plus the need of safeguards in tests).

This topic was automatically closed after 45 days. New replies are no longer allowed.


If you have a query related to it or one of the replies, start a new topic and refer back with a link.