Title: | Install / Unstall KWB Packages and Show Package Dependencies |
---|---|
Description: | This package contains some helper functions for (un-)installing KWB packages and for showing package dependencies. The function of main interest may be updateKwbPackages() that checks for the latest package version on KWB's server and installs the packages from there if required. |
Authors: | Hauke Sonnenberg [aut, cre] , Michael Rustler [ctb] , FAKIN [fnd], OPTIWELLS-2 [fnd], Kompetenzzentrum Wasser Berlin gGmbH [cph] |
Maintainer: | Hauke Sonnenberg <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.4.0 |
Built: | 2024-11-01 04:39:43 UTC |
Source: | https://github.com/KWB-R/kwb.package |
Add Labels to the Nodes Drawn on a Circle Line
addNodeLabels(nodes, cex = 1, distance.factor = 1)
addNodeLabels(nodes, cex = 1, distance.factor = 1)
nodes |
data frame as returned by |
cex |
character expansion factor as given to |
distance.factor |
expansion factor applied to the x and y coordinates of the nodes to get the coordinates of the labels |
Convert angles in a unit circle to point coordinates (x, y)
anglesToPoints(angles.grad)
anglesToPoints(angles.grad)
angles.grad |
vector of angles in degree |
matrix with columns x and y containing the coordinates of points corresponding to the given angles in a unit circle
plot(anglesToPoints(equidistantAngles(n = 10)), type = "b")
plot(anglesToPoints(equidistantAngles(n = 10)), type = "b")
Archived CRAN versions
archivedCranVersions(package, ref_date = NULL)
archivedCranVersions(package, ref_date = NULL)
package |
package name |
ref_date |
default: NULL |
packages <- c("ggplot2", "swmmr", "kwb.hantush") archivedCranVersions(packages) archivedCranVersions(packages, ref_date= "2012-12-01")
packages <- c("ggplot2", "swmmr", "kwb.hantush") archivedCranVersions(packages) archivedCranVersions(packages, ref_date= "2012-12-01")
Compare Package Versions Between Libraries
compareInstalledVersions(lib1, lib2)
compareInstalledVersions(lib1, lib2)
lib1 |
path to first R library |
lib2 |
path to second R library |
data frame with columns name
(package name), version.1
,
version.2
(version string of package in lib1
and lib2
,
respectively), differs
(logical indicating whether the version is
different in the two libraries)
Copy Base R Packages from the System Library to the Target Library
copyBasePackages( target_lib, set_number = 2L, system_lib = utils::tail(.libPaths(), 1L), packages = systemPackages(set_number) )
copyBasePackages( target_lib, set_number = 2L, system_lib = utils::tail(.libPaths(), 1L), packages = systemPackages(set_number) )
target_lib |
path to the target library |
set_number |
number defining the base packages to be copied, see
|
system_lib |
path to the system library from which to copy packages |
packages |
vector of names of packages to be copied |
Get versions of CRAN packages
cranVersions(name, dbg = TRUE)
cranVersions(name, dbg = TRUE)
name |
package name |
dbg |
logical indicating whether or not to show debug messages. Default:
|
Default Package Directory
defaultPackageDir()
defaultPackageDir()
Detach all Non-System Packages
detachAllNonSystemPackages()
detachAllNonSystemPackages()
Detach a package and all the depending packages
detachRecursively(package, pattern = ".*", dbg = FALSE)
detachRecursively(package, pattern = ".*", dbg = FALSE)
package |
name of package to be detached |
pattern |
pattern matching the names of depending packages that are actually to be detached, e.g. use pattern = "^kwb\." to only detach kwb packages. Default: ".*" (matching all package names) |
dbg |
if |
Download an R Package from GitHub
downloadGitHubPackage(repo, destdir = "~/../Downloads")
downloadGitHubPackage(repo, destdir = "~/../Downloads")
repo |
path to repository, relative to https://github,com, e.g. "kwb-r/kwb.utils" |
destdir |
path to download folder, default: "~/../Downloads" |
path to downloaded file in the destdir
folder with attribute
"origin" pointing to the original file in tempdir()
.
Download Package Archive from Microsoft R Archive Network
downloadPackagesFromSnapshot( packages, snapshot_date, destdir = NULL, type = c("source", "win.binary")[1L] )
downloadPackagesFromSnapshot( packages, snapshot_date, destdir = NULL, type = c("source", "win.binary")[1L] )
packages |
names of packages (vector of character) |
snapshot_date |
date of snapshot of CRAN package versions, as a string in yyyy-mm-dd format |
destdir |
path to download folder |
type |
one of |
paths to the downloaded files (vector of character)
Draw Lines between Nodes
drawDependencies(nodes, dependencies, nodeColours, ...)
drawDependencies(nodes, dependencies, nodeColours, ...)
nodes |
data frame as returned by |
dependencies |
list of package dependencies as returned by
|
nodeColours |
colours given to the lines starting at the same start node |
... |
arguments passed to |
Equidistantly Distributed Angles in Degrees Between 0 and 360
equidistantAngles(n, from = 0)
equidistantAngles(n, from = 0)
n |
number of angles to be returned |
from |
start angle in degrees. Default: 0 |
x <- equidistantAngles(90) plot(x, sin(gradToRad(x)), xlab = "angle in degree", ylab = "sin(angle)")
x <- equidistantAngles(90) plot(x, sin(gradToRad(x)), xlab = "angle in degree", ylab = "sin(angle)")
Example Links and Nodes
exampleLinksAndNodes()
exampleLinksAndNodes()
Get Information on Package Authors
getAuthors(package)
getAuthors(package)
package |
name of (installed) package |
Get Matrix with Information on All CRAN Packages
getCranPackageDatabase()
getCranPackageDatabase()
Get Package Dependency Data from Package Database
getDependencyData( db, fields = c("Depends", "Imports", "LinkingTo", "Suggests", "Enhances") )
getDependencyData( db, fields = c("Depends", "Imports", "LinkingTo", "Suggests", "Enhances") )
db |
package data base as e.g. returned by
|
fields |
types of dependencies to be considered. Default:
|
Get paths/names of package files available in a directory
getPackageFilesToInstall( package.dir = defaultPackageDir(), packageNames = NULL, filepattern = "", full.names = TRUE, dbg = FALSE, warn = TRUE )
getPackageFilesToInstall( package.dir = defaultPackageDir(), packageNames = NULL, filepattern = "", full.names = TRUE, dbg = FALSE, warn = TRUE )
package.dir |
full path to directory containing the package files |
packageNames |
optional vector of character containing the names of the packages to be installed. If NULL (default), all available packages in package.dir are installed, |
filepattern |
pattern matching names of files to be considered. Default: "^kwb\..*\.zip$" |
full.names |
if TRUE (default) the full paths to the package files are returned, else only the file names |
dbg |
if |
warn |
if |
character vector containing the full paths to or just the names of the available package files
Which Licences are Specified for the Packages?
getPackageLicences(packages, db = utils::installed.packages())
getPackageLicences(packages, db = utils::installed.packages())
packages |
names of (installed) packages |
db |
optional. Package database, similar to what is returned by
|
data frame
Helper: Get R major minor version string
getRVersionMajorMinor()
getRVersionMajorMinor()
returns R version major.minor string (e.g. 4.0), used by standard R libraries for grouping all R packages into one folder
getRVersionMajorMinor()
getRVersionMajorMinor()
Get Versions of Packages on GitHub
githubVersions(name, github_user = "KWB-R")
githubVersions(name, github_user = "KWB-R")
name |
package name |
github_user |
name of github account, default: "KWB-R" |
data frame with one row per available version
githubVersions("kwb.utils")
githubVersions("kwb.utils")
Angle in Degree to Angle in rad
gradToRad(grad)
gradToRad(grad)
grad |
vector of angles in degrees |
gradToRad(c(0, 90, 180, 270, 360)) / pi
gradToRad(c(0, 90, 180, 270, 360)) / pi
Do Packages have a GPL Licence?
hasGplLicence(packages)
hasGplLicence(packages)
packages |
package name(s) as a vector of character |
vector of logical
Create the folder structure for a local CRAN-like repository
initLocalCRAN(local_cran)
initLocalCRAN(local_cran)
local_cran |
full path to the folder representing the local CRAN |
What Versions of Package Dependencies are Installed?
installedDependencies(package, recursive = TRUE)
installedDependencies(package, recursive = TRUE)
package |
name of the package of which to check the dependencies |
recursive |
whether to look recursively for dependencies or only for the
direct dependencies of |
installedDependencies(package = "kwb.package") installedDependencies(package = "kwb.package", recursive = FALSE)
installedDependencies(package = "kwb.package") installedDependencies(package = "kwb.package", recursive = FALSE)
Installed KWB-Packages
installedKwbPackages()
installedKwbPackages()
vector of names of installed kwb-packages
Install GitHub Packages
installGithubPackages( lib, repos, dependencies = TRUE, upgrade = "never", auth_token = Sys.getenv("GITHUB_PAT") )
installGithubPackages( lib, repos, dependencies = TRUE, upgrade = "never", auth_token = Sys.getenv("GITHUB_PAT") )
lib |
path to R library where packages should be installed |
repos |
vector of relative paths to GitHub repositories containing R packages (e.g. "kwb-r/kwb.utils") |
dependencies |
passed to remotes::install_github(). TRUE is shorthand for "Depends", "Imports", "LinkingTo" and "Suggests" NA is shorthand for "Depends", "Imports" and "LinkingTo" and is the default. FALSE is shorthand for no dependencies (i.e. just check this package, not its dependencies), (default: TRUE) |
upgrade |
passed to |
auth_token |
GitHub Personal Access token, required with scope "private" if access to non-public R packages is required (default: Sys.getenv("GITHUB_PAT")) |
installs multiple GitHub R packages into one R library
## Not run: remotes::install_github("kwb-r/pkgmeta") pkgs <- pkgmeta::get_github_packages() paths_list <- list( r_version = kwb.packages::getRVersionMajorMinor(), lib_linux = "/usr/lib/R/site-library", lib_win = "<win_root_dir>/kwbran/<r_version>" ) paths <- kwb.utils::resolve(paths_list, win_root_dir = tempdir()) pkgs <- pkgmeta::get_github_packages() installGithubPackages(lib = paths$lib_win, pkgs$full_name) installGithubPackages(lib = paths$lib_linux, pkgs$full_name) ## End(Not run)
## Not run: remotes::install_github("kwb-r/pkgmeta") pkgs <- pkgmeta::get_github_packages() paths_list <- list( r_version = kwb.packages::getRVersionMajorMinor(), lib_linux = "/usr/lib/R/site-library", lib_win = "<win_root_dir>/kwbran/<r_version>" ) paths <- kwb.utils::resolve(paths_list, win_root_dir = tempdir()) pkgs <- pkgmeta::get_github_packages() installGithubPackages(lib = paths$lib_win, pkgs$full_name) installGithubPackages(lib = paths$lib_linux, pkgs$full_name) ## End(Not run)
Install the remotes Package to the Given Library
installRemotes(lib)
installRemotes(lib)
lib |
path to the library to which to install the remotes package |
This is just a wrapper around package_dependencies
with
some defaults defined.
packageDependencies( packages = NULL, db = utils::installed.packages(), which = c("Depends", "Imports", "LinkingTo", "Suggests", "Enhances")[1:3], recursive = TRUE, reverse = FALSE, verbose = FALSE )
packageDependencies( packages = NULL, db = utils::installed.packages(), which = c("Depends", "Imports", "LinkingTo", "Suggests", "Enhances")[1:3], recursive = TRUE, reverse = FALSE, verbose = FALSE )
packages |
a character vector of package names. |
db |
character matrix as from |
which |
a character vector listing the types of
dependencies, a subset of
|
recursive |
a logical indicating whether (reverse) dependencies
of (reverse) dependencies (and so on) should be included, or a
character vector like |
reverse |
logical: if |
verbose |
logical indicating if output should monitor the package search cycles. |
Package Dependencies by Type
packageDependenciesByType( packages = NULL, db = utils::installed.packages(), which = c("Depends", "Imports", "LinkingTo", "Suggests", "Enhances")[1:3], recursive = TRUE, reverse = FALSE, verbose = FALSE )
packageDependenciesByType( packages = NULL, db = utils::installed.packages(), which = c("Depends", "Imports", "LinkingTo", "Suggests", "Enhances")[1:3], recursive = TRUE, reverse = FALSE, verbose = FALSE )
packages |
a character vector of package names. |
db |
character matrix as from |
which |
a character vector listing the types of
dependencies, a subset of
|
recursive |
a logical indicating whether (reverse) dependencies
of (reverse) dependencies (and so on) should be included, or a
character vector like |
reverse |
logical: if |
verbose |
logical indicating if output should monitor the package search cycles. |
Package String
packageString(package)
packageString(package)
package |
Package name |
package
, preceded by package:
Plot all Package Dependencies
plotAllDependencies(dependencies, r = 1.5, for.each = TRUE, ...)
plotAllDependencies(dependencies, r = 1.5, for.each = TRUE, ...)
dependencies |
list of package dependencies as returned by
|
r |
radius of the unit circle in which to arrange the package names.
Passed to |
for.each |
if |
... |
arguments passed to |
kwb.packages <- installedKwbPackages() # Plot all (direct and indirect) dependencies of installed kwb packages plotAllDependencies(packageDependencies(kwb.packages)) # Plot only direct dependencies plotAllDependencies(packageDependencies(kwb.packages, recursive = FALSE))
kwb.packages <- installedKwbPackages() # Plot all (direct and indirect) dependencies of installed kwb packages plotAllDependencies(packageDependencies(kwb.packages)) # Plot only direct dependencies plotAllDependencies(packageDependencies(kwb.packages, recursive = FALSE))
Plot Dependencies Between Nodes on a Circle Line
plotDependencies( nodes, dependencies, main = "", r = 1.5, nodeColours = grDevices::rainbow(nrow(nodes)), ... )
plotDependencies( nodes, dependencies, main = "", r = 1.5, nodeColours = grDevices::rainbow(nrow(nodes)), ... )
nodes |
data frame as returned by |
dependencies |
list of package dependencies as returned by
|
main |
plot title |
r |
radius of the circle |
nodeColours |
colours to be given to the nodes |
... |
passed to |
Plot Nodes
plotNodes(nodes, r = 1, col = "red", ...)
plotNodes(nodes, r = 1, col = "red", ...)
nodes |
data frame as returned by |
r |
Radius of a circle that fits into the plot range: xlim is set to
|
col |
colour used to plot the nodes (default: "red") |
... |
arguments passed to |
Plot Package Versions
plotPackageVersions( versions, r_range = c(1, 10), rmax = 1.1 * r_range[2L], dphi = NULL, ticklen = 1 )
plotPackageVersions( versions, r_range = c(1, 10), rmax = 1.1 * r_range[2L], dphi = NULL, ticklen = 1 )
versions |
versions |
r_range |
r_range (default: c(1, 10)) |
rmax |
rmax (default: 1.1 * r_range[2L]) |
dphi |
dphi (default: NULL) |
ticklen |
ticklen (default: 1) |
Plot Sankey Network
plotSankeyNetwork(functionName, where = 1, ...)
plotSankeyNetwork(functionName, where = 1, ...)
functionName |
name of function from which to start the network |
where |
passed to |
... |
additional arguments passed to |
Provide a Source Package in the Local Cran
provideInLocalCRAN( package, rebuild = TRUE, local_cran = defaultLocalCRAN(drive_letter = TRUE) )
provideInLocalCRAN( package, rebuild = TRUE, local_cran = defaultLocalCRAN(drive_letter = TRUE) )
package |
name of the package to be looked up in either of these
locations: |
rebuild |
logical. If |
local_cran |
full path to the folder representing the local CRAN |
Read DESCRIPTION File for R Package on GitHub
readGithubPackageDescription( repo, sha, auth_token = remotes_github_pat(), destdir = tempdir() )
readGithubPackageDescription( repo, sha, auth_token = remotes_github_pat(), destdir = tempdir() )
repo |
GitHub repository, e.g. "kwb-r/kwb.utils" |
sha |
SHA (hash) of the commit |
auth_token |
GitHub token |
destdir |
path to destination directory, i.e. directory to which the
DESCRIPTION file is copied. Default: |
Add the path to the local repository to the option "repos" and set the option "pkgType" to "source".
setOptionsForPackrat()
setOptionsForPackrat()
The old options are returned invisibly.
Names of depending packages in the order of their dependency
sortedDependencies(package, dbg = FALSE)
sortedDependencies(package, dbg = FALSE)
package |
name of package(s) of which dependencies are to be found |
dbg |
if |
vector of package names. The first element is the package itself, followed by the names of depending packages. You should be able to detach the packages in this order without any "package ... is required by ..." error
Is a Package Installed?
stopIfNotInstalled(package)
stopIfNotInstalled(package)
package |
package name (character vector of length one) |
Names of Base R Packages
systemPackages(set_number = 1L)
systemPackages(set_number = 1L)
set_number |
integer number specifying a set of packages: 1 or 2. |
vector of character representing package names
Convert Links to List of Links and Nodes
toLinksAndNodes(links)
toLinksAndNodes(links)
links |
list with elements |
list with elements links
(input list links
with new
elements value
, source
, target
) and nodes
(data frame with column name
)
kwb.package:::toLinksAndNodes(list( source = c("s1", "s1"), target = c("t1", "t2") ))
kwb.package:::toLinksAndNodes(list( source = c("s1", "s1"), target = c("t1", "t2") ))
Node names to node coordinates in a unit circle
toNodes(nodeNames)
toNodes(nodeNames)
nodeNames |
character vector of nodes to be arranged in a unit circle |
data frame with columns x
and y
giving the coordinates
of the nodes arranged in a circle. The row names represent the node names.
nodes <- toNodes(LETTERS) plot(nodes) text(nodes, labels = row.names(nodes), adj = c(0, 0))
nodes <- toNodes(LETTERS) plot(nodes) text(nodes, labels = row.names(nodes), adj = c(0, 0))
Update installed KWB-packages or install KWB-packages for the first time
updateKwbPackages( packageNames = sort(installedKwbPackages()), skip = character(), package.dir = defaultPackageDir() )
updateKwbPackages( packageNames = sort(installedKwbPackages()), skip = character(), package.dir = defaultPackageDir() )
packageNames |
vector of packages to be installed. Default: names of all installed KWB-packages |
skip |
vector of packages not to be installed, even if they are listed in packageNames |
package.dir |
full path to the folder containing the binary package files |