0

One of my R packages is going to be deprecated and replaced by a better one, an instead of removing from github I want to add a message/warning that appears when user installed/loaded it, to redirect users to new package

Searched somewhere but did'nt find how to do such thing

Forge
  • 1,587
  • 1
  • 15
  • 36
  • 3
    https://github.com/tidyverse/ggplot2/blob/master/R/zzz.r – Roland Jul 16 '17 at 10:54
  • Thanks Roland but this code is loaded automagically or is needed to be called from somewhere in my code. – Forge Jul 16 '17 at 11:10
  • Read [Hadley's book](http://r-pkgs.had.co.nz/r.html), and in particular the section towards the end 'When you do need side effects'. And of course, [ns-hooks](https://stat.ethz.ch/R-manual/R-devel/library/base/html/ns-hooks.html) - hooks for namespace events – SymbolixAU Jul 16 '17 at 11:23

1 Answers1

1

Add a zzz.R file in your package containing:

.onLoad <- function(libname, pkgname) {
      packageStartupMessage("Your message here", domain = NULL, appendLF = TRUE)
    }

Just mention all your R files using 'Collation' in DESCRIPTION package

useRj
  • 1,232
  • 1
  • 9
  • 15