Adds package(s) to a SsimLibrary
.
Usage
addPackage(ssimLibrary, packages, versions = NULL, forceUpdate = FALSE)
# S4 method for class 'character'
addPackage(ssimLibrary, packages, versions = NULL, forceUpdate = FALSE)
# S4 method for class 'SsimLibrary'
addPackage(ssimLibrary, packages, versions = NULL, forceUpdate = FALSE)
Arguments
- ssimLibrary
SsimLibrary
object- packages
character string or vector of package name(s)
- versions
character string or vector of package version(s). If
NULL
then uses the latest installed version of the package- forceUpdate
logical. If
FALSE
(default) user will be prompted to approve any required updates. IfTRUE
, required updates will be applied silently.
Value
Invisibly returns TRUE
upon success (i.e.successful addition
of the package) or FALSE
upon failure.
Examples
# \donttest{
# Install "stsim" and "stsimecodep" SyncroSim packages
installPackage(packages = c("stsim", "stsim"),
versions = c("4.0.0", "4.0.1"))
#> [1] "Package stsim v4.0.0 is not available from package server."
#> [1] "Package stsim v4.0.1 is already installed."
installPackage("stsimecodep")
#> Package <stsimecodep v4.0.0> installed
# Specify file path and name of new SsimLibrary
myLibraryName <- file.path(tempdir(), "testlib")
# Set up a SyncroSim Session, SsimLibrary, and Project
mySession <- session()
myLibrary <- ssimLibrary(name = myLibraryName, session = mySession)
# Add package
addPackage(myLibrary, packages = "stsim", versions = "4.0.1")
#> Package <stsim v4.0.1> added
addPackage(myLibrary, packages = "stsimecodep")
#> Package <stsimecodep v4.0.0> added
packages(myLibrary)
#> name
#> 1 core
#> 2 stsim
#> 3 stsimecodep
#> description
#> 1 SyncroSim Core Package
#> 2 The ST-Sim state-and-transition simulation model
#> 3 Calculates TNC's unified ecological departure from reference conditions in ST-Sim
#> version schema
#> 1 3.0.9 3
#> 2 4.0.1 4
#> 3 4.0.0 4
#> status
#> 1 OK
#> 2 OK
#> 3 Info - The 'stsimecodep' Package was built for version '4.0.0' of the 'stsim' Package.
# Change package version
addPackage(myLibrary, packages = "stsim", versions = "4.0.0")
#> [1] "Package stsim v4.0.0 is not among the available packages."
addPackage(myLibrary, packages = "stsim", versions = "4.0.1")
#> [1] "stsim v4.0.1 has already been added to the ssimLibrary"
# Remove package
removePackage(myLibrary, packages = c("stsim", "stsimecodep"))
#> Package <stsim> removed
#> Package <stsimecodep> removed
packages(myLibrary)
#> name description version schema status
#> 1 core SyncroSim Core Package 3.0.9 3 OK
# }