% 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 on 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 %>
<% m = co_heaviness(pkg)
if(nrow(m) > 1) {
if(attr(m, "max") > 10) {
m2 = co_heaviness(pkg, jaccard = TRUE)
pair1 = NULL
pair2 = NULL
hv1 = NULL
hv2 = NULL
nr = nrow(m)
for(i in 1:(nr-1)) {
for(j in (i+1):nr) {
if(m[i, j] > 10) {
pair1 = c(pair1, rownames(m)[i])
pair2 = c(pair2, rownames(m)[j])
hv1 = c(hv1, m[i, j])
hv2 = c(hv2, m2[i, j])
}
}
}
co_tb = data.frame(pair1 = pair1, pair2 = pair2, heaviness = hv1, jaccard = round(hv2, 3))
co_tb = co_tb[order(co_tb$heaviness, decreasing = TRUE), , drop = FALSE]
if(pkgndep_opt$add_link) {
co_tb[, 1] = qq("
@{co_tb[, 1]} ", collapse = FALSE)
co_tb[, 2] = qq("
@{co_tb[, 2]} ", collapse = FALSE)
} else {
co_tb[, 1] = qq("
@{co_tb[, 1]} ", collapse = FALSE)
co_tb[, 2] = qq("
@{co_tb[, 2]} ", collapse = FALSE)
}
%>
The following table lists pairs of parent packages with co-heaviness larger than 10. The co-heaviness measures the number of additional
dependencies that two parent packages simultaneously import and are only imported by the two parents.
Note the co-heaviness from parents can be always easily observed in the dependency heatmap.
<%= as.character(knitr::kable(co_tb, format = "html", row.names = FALSE, escape = FALSE, col.names = c("Parent 1", "Parent 2", qq("Co-heaviness on @{pkg$package}"), "Co-heaviness as Jaccard coeffcient"), table.attr = "class='table table-striped' style='width:900px'" )) %>
<% }
}
%>
<% } else { %>
No dependency found.
<% } %>
Analysis was done with pkgndep .