% add_js = function(f) {
code = readLines(base64::encode(system.file("www", "_js", f, package = "pkgndep"), linebreaks= FALSE))
paste0('')
}
add_css = function(f) {
suppressWarnings(code <- paste(readLines(system.file("www", "_css", f, package = "pkgndep")), collapse = "\n"))
paste0("")
}
%>
Dependency analysis for package <%=pkg$package%>
General information
<% if(grepl("bioconductor", pkg$repository)) { %>
Bioconductor link link
<% } else { %>
CRAN link link
<% } %>
Package version <%= pkg$version%>
Number of strong dependencies <%= pkg$n_by_strong %>
Number of all dependencies <%= pkg$n_by_all %>
Number of parent packages <%= sum(pkg$which_required) %>
Max heaviness from parent packages <%= if(any(pkg$which_required)) max(pkg$heaviness[pkg$which_required]) else 0 %>
Total heaviness from parent packages <%= if(any(pkg$which_required)) sum(pkg$heaviness[pkg$which_required]) else 0 %>
Number of parent packages (including Suggests
and Enhances
) <%= length(pkg$heaviness) %>
<% m = co_heaviness(pkg)
diag(m) = -Inf
if(nrow(m) >= 2) {
if(max(m) > 0) {
ind = which(m == max(m), arr.ind = TRUE)
rn = rownames(m)
%>
Max co-heaviness from parent packages (<%=rn[ind[1, 1]]%> and <%=rn[ind[1, 2]]%> ) <%= max(m) %>
<% }
} %>
Dependency heatmap
In the following dependency heatmap, rows are the parent packages of <%=pkg$package%> and columns are the dependency packages that each parent package brings in.
On the right side of the heatmap, there are three barplot annotations: 1. number of imported functions/S4 methods/S4 classes from parent packages; 2. number of
dependency packages from each parent package; 3. heaviness of each parent package on <%=pkg$package%> .
Adjust heatmap size:
increase
decrease
reset
<% tmp_file = tempfile(fileext = ".svg")
plot(pkg, file = tmp_file)
%>
<%= paste0(readLines(tmp_file), collapse = "\n")%>
<% file.remove(tmp_file) %>
Dependency table
<% if(n_total > 0) { %>
<%
if(grepl("(bioc|books|annotation|experiment|workflow)", pkg$repository)) {
namespace_link = paste0("https://code.bioconductor.org/browse/", pkg$package, "/blob/master/NAMESPACE")
} else if(pkg$package %in% BASE_PKGS) {
namespace_link = paste0("https://github.com/wch/r-source/blob/trunk/src/library/", pkg$package, "/NAMESPACE")
} else {
namespace_link = paste0("https://github.com/cran/", pkg$package, "/blob/master/NAMESPACE")
}
%>
"Import" information is from the NAMESPACE file of <%=pkg$package%> .
imports: number of imported functions/objects; importMethods : number of imported S4 methods; importClasses : number of imported S4 classes.
Required packages: number of strong dependency packages for each of the parent package (or in other words, number of dependency packages the parent package brings in).
Heaviness from parent on <%=pkg$package%> : number of required packages that can be reduced if moving parent package to Suggests
of <%=pkg$package%> .
<%
if(pkgndep_opt$add_link) {
tb[, 1] = qq("
@{tb[, 1]} ", collapse = FALSE)
} else {
tb[, 1] = qq("
@{tb[, 1]} ", collapse = FALSE)
}
html_tb = as.character(knitr::kable(tb, format = "html", row.names = FALSE, escape = FALSE, col.names = c("Parent package", "Field", "imports", "importMethods", "importClasses", "Required packages", qq("Heaviness from parent on
@{pkg$package} ")), table.attr = "class='table table-striped' id='parent-dependency'", align = c("l", rep("r", ncol(tb) - 1))))
html_tb = gsub("(
]*?> Suggests \\s+)
]*?> 0 \\s+
]*?> 0 \\s+
]*?> 0 \\s+", qq("\\1
No object is imported into the namespace of @{pkg$package} . \n"), html_tb)
html_tb = gsub("(
]*?> Enhances \\s+)
]*?> 0 \\s+
]*?> 0 \\s+
]*?> 0 \\s+", qq("\\1
No object is imported into the namespace of @{pkg$package} . \n"), html_tb)
html_tb = gsub("(
]*?> Depends \\s+)
]*?> 0 \\s+
]*?> 0 \\s+
]*?> 0 \\s+", qq("\\1
The whole set of functions/methods/classes from parent package is imported to the namespace of @{pkg$package} . \n"), html_tb)
html_tb = gsub("(
]*?> Depends \\s+)
]*?> -(\\d+) \\s+
]*?> 0 \\s+
]*?> 0 \\s+", qq("\\1
The whole set of functions/methods/classes from parent package excluding \\2 objects is imported to the namespace of @{pkg$package} . \n"), html_tb)
html_tb = gsub("(
]*?> Depends \\s+)
]*?> -Inf \\s+
]*?> 0 \\s+
]*?> 0 \\s+", qq("\\1
Parent package is listed in Depends
of @{pkg$package} but no object from parent package is imported. \n"), html_tb)
html_tb = gsub("(
]*?> Imports \\s+)
]*?> 0 \\s+
]*?> 0 \\s+
]*?> 0 \\s+", qq("\\1
The whole set of functions/methods/classes from parent package is imported to the namespace of @{pkg$package} . \n"), html_tb)
html_tb = gsub("(
]*?> Imports \\s+)
]*?> -(\\d+) \\s+
]*?> 0 \\s+
]*?> 0 \\s+", qq("\\1
The whole set of functions/methods/classes from parent package excluding \\2 objects is imported to the namespace of @{pkg$package} . \n"), html_tb)
html_tb = gsub("(
]*?> Imports \\s+)
]*?> -Inf \\s+
]*?> 0 \\s+
]*?> 0 \\s+", qq("\\1
Parent package is listed in Imports
of @{pkg$package} but no object from parent package is imported. \n"), html_tb)
html_tb = gsub("(
]*?> LinkingTo \\s+)
]*?> 0 \\s+
]*?> 0 \\s+
]*?> 0 \\s+", qq("\\1
No object is imported into the namespace of @{pkg$package} . \n"), html_tb)
html_tb = gsub("(
]*?> LinkingTo \\s+)
]*?> -(\\d+) \\s+
]*?> 0 \\s+
]*?> 0 \\s+", qq("\\1
The whole set of functions/methods/classes from parent package excluding \\2 objects is imported to the namespace of @{pkg$package} . \n"), html_tb)
html_tb = gsub("(
]*?> LinkingTo \\s+)
]*?> -Inf \\s+
]*?> 0 \\s+
]*?> 0 \\s+", qq("\\1
Parent package is listed in LinkingTo
of @{pkg$package} but no object from parent package is imported. \n"), html_tb)
%>
<%= html_tb %>
<% } else { %>
No dependency found.
<% } %>
Analysis was done with pkgndep .