Learn R Programming

mvbutils (version 2.5.101)

install.pkg: Package building, distributing, and checking

Description

These are convenient wrappers for R{}'s package creation and installation tools. They are designed to be used on packages created from tasks via mvbutils. However, the mvbutils approach deliberately makes re-installation a rare event, and one call to install.pkg might suffice for the entire life of a simple package. After that very first installation, you'd probably only need to call install.pkg if (when...

Usage

install.pkg( pkg, character.only=FALSE, dir.above.source='+', lib=.libPaths()[1], intern=TRUE)
  build.pkg( pkg, character.only=FALSE, dir.above.source='+', intern=TRUE)
  build.pkg.binary( pkg, character.only=FALSE, dir.above.source='+', intern=TRUE)
  check.pkg( pkg, character.only=FALSE, dir.above.source='+', intern=TRUE)
  set.rcmd.vars( ...) # not yet implemented. If you need to set env vars eg PATH for R CMD to work, you have to do so yourself; see *Details*

Arguments

pkg
usually an unquoted package name, but interpretation can be changed by non-default character.only
character.only
default FALSE. If TRUE, treat pkg as a normal object, which should therefore be a string containing the package's name. If character.only is itself a string, it will override pkg and be treated as the name of the pac
dir.above.source
where to look for source package; see pre.install
intern
?return the result as a character vector? (See system) Set to FALSE if you want to see the output as-it-happens, but in that case it won't be returned.
lib
where to install to
...
name-value pairs of system environment variables (not used for now)

Value

  • If intern=TRUE: the stuff printed out, with class cat so it prints nicely. If intern=FALSE: various things about the paths (purely for my programming convenience).

code

set.rcmd.vars

Details

Before doing any of this, you need to have used pre.install to create a source package. (Or patch.install, if you've done all this before and just want to re-install/build/check for some reason.) install.pkg calls "R CMD INSTALL" to install from a source package. build.pkg calls "R CMD build" to wrap up the source package into a "tarball", as required by CRAN and also for distribution to non-Windows-and-Mac platforms. build.pkg.binary (Windows & Mac only) calls "R CMD INSTALL --build" to generate a binary package. A temporary installation directory is used, so your existing installation is not overwritten or deleted if there's a problem; R{} CMD INSTALL --build has a nasty habit of doing just that unless you're careful, which build.pkg.binary is. check.pkg calls "R CMD check" after first calling build.pkg (more efficiently, I should perhaps try to work out whether there's an up-to-date tarball already). I should probably allow control of the plethora of checks via appropriate flags, perhaps via the pre-install-hook somehow. However, my understanding that CRAN insists on the full monty, regardless of what you think makes sense for your package. [It may also be possible to do some checks directly from R{} via functions in the utils package, but NB the possibility of interference with your current R{} session; for example, codoc attempts to unload & load the package.] You may have to set some environment variables (eg PATH, and perhaps R_LIBS) for the underlying R{} CMD calls to work. Currently you have to do this manually--- your .First or .Rprofile would be a good place. If you really object to changing these for the whole R{} session, let me know; I've left a placeholder for a function set.rcmd.vars that could store a list of environment variables to be set temporarily for the duration of the R{} CMD calls only, but I haven't implemented it (and won't unless there's demand).

Examples

Run this code
# First time package installation
# Must be cd()ed to task above 'mvbutils'
maintain.packages( mvbutils)
pre.install( mvbutils)
install.pkg( mvbutils)
# Subsequent maintenance is all done by:
patch.install( mvbutils)
# For distro to
build.pkg( mvbutils)
# or on Windows (?and Macs?)
build.pkg.binary( mvbutils)
# If you enjoy R CMD CHECK:
check.pkg( mvbutils)

Run the code above in your browser using DataLab