[R-pkg-devel] package in 'Suggests'

David C Sterratt david.c.sterratt at ed.ac.uk
Thu Oct 20 15:07:37 CEST 2016


Dear Lorenzo,

For my "retistruct" package, which depends on gWidgets2RGtk2, I have
gWidgets2RGtk2, gWidgets2 and cairoDevice as "Suggests" and I put the
following code in the function that opens the GUI ('retistruct()' in
https://github.com/davidcsterratt/retistruct/blob/master/pkg/retistruct/R/retistruct-gui.R):

  guiToolkit <- "RGtk2"
  require.package <- function(pkg) {
    suggests<-tools::package.dependencies(installed.packages()["retistruct",], depLevel="Suggests")$retistruct
    suggests <- suggests[suggests[,1] == pkg]
    uptodate <- ifelse(is.na(suggests[2]),
                       TRUE,
                       eval(parse(text=paste("packageVersion(suggests[1])", suggests[2],  "suggests[3]"))))
    if (!require(pkg, character.only=TRUE) |
        !uptodate) {
      message(paste("Trying to install required package", pkg))
      install.packages(pkg)
      if (!require(pkg, character.only=TRUE)) {
        stop(paste("Could not install", pkg))
      }
    }
  }
  require.package(paste0("gWidgets2", guiToolkit))
  require.package("cairoDevice")
  options(guiToolkit=guiToolkit)


The package can work without a GUI, and may be installed on systems that
do not have GTK installed. There is user documentation on installing
RGtk2 which, if it's useful to you, you could of course copy:
http://retistruct.r-forge.r-project.org/retistruct-user-guide.pdf

Best wishes,

David.

--
David C Sterratt, Research Fellow - http://homepages.inf.ed.ac.uk/sterratt
Institute for Adaptive and Neural Computation     tel: +44 131 651 1739
School of Informatics, University of Edinburgh    fax: +44 131 650 6899
Informatics Forum, 10 Crichton Street, Edinburgh EH8 9AB, Scotland, UK

-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.



More information about the R-package-devel mailing list