Skip to content

Commit

Permalink
Merge pull request #23 from DominikRafacz/release/0.3
Browse files Browse the repository at this point in the history
release 0.3.0
  • Loading branch information
DominikRafacz authored Dec 9, 2021
2 parents 7257215 + 8e76e4f commit 982f153
Show file tree
Hide file tree
Showing 31 changed files with 1,491 additions and 1,356 deletions.
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
Package: deepdep
Title: Visualise and Explore the Deep Dependencies of R Packages
Version: 0.2.5.4
Version: 0.3.0
Authors@R: c(person("Dominik", "Rafacz", email = "[email protected]",
role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-0925-1909")),
person("Hubert", "Baniecki", role = c("aut")),
person("Szymon", "Maksymiuk", role = c("aut")),
person("Mateusz", "Bakala", role = c("aut")))
person("Laura", "Bakala", role = c("aut")),
person("Dirk", "Eddelbuettel", role = c("ctb")))
Description: Provides tools for exploration of R package dependencies.
The main deepdep() function allows to acquire deep dependencies of any package and plot them in an elegant way.
It also adds some popularity measures for the packages e.g. in the form of download count through the 'cranlogs' package.
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# deepdep 0.3.0
* adjusted `dependency_type` argument to be consistent with `tools` package (issue #19)
* added `show_stamp` parameter for plot function (issue #20)

# deepdep 0.2.5
* wrapped `deepdep` in tests with `tryCatch` in case of R-devel and Bioc-devel versions mismatch
* marked all non-local examples with "donttest"
Expand Down
33 changes: 25 additions & 8 deletions R/get_dependencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
#' @param bioc A \code{logical} value. If \code{TRUE} the Bioconductor dependencies data will be taken from the
#' Bioconductor repository. For this option to work properly, \code{BiocManager} package needs to be installed.
#' @param local A \code{logical} value. If \code{TRUE} only data of locally installed packages will be used (without API usage).
#' @param dependency_type A \code{character} vector. Types of the dependencies that should be sought.
#' Possibilities are: \code{"Imports", "Depends", "Suggests", "Enhances", "LinkingTo"}. By default it's \code{"Depends", "Imports"}.
#' @param dependency_type A \code{character} vector. Types of the dependencies that should be sought, a subset of
#' \code{c("Imports", "Depends", "LinkingTo", "Suggests", "Enhances")}. Other possibilities are: character string
#' \code{"all"}, a shorthand for the whole vector; character string \code{"most"} for the same vector without \code{"Enhances"};
#' character string \code{"strong"} (default) for the first three elements of that vector. Works analogously to
#' \code{\link[tools]{package_dependencies}}.
#'
#' @return An object of \code{package_dependencies} class.
#'
Expand All @@ -29,16 +32,12 @@
#'
#' @export
get_dependencies <- function(package, downloads = TRUE, bioc = FALSE, local = FALSE,
dependency_type = c("Depends", "Imports")) {
dependency_type = "strong") {

if (downloads && (local || bioc)) stop("If you use downloads, you cannot use",
" neither bioc nor local")

possible_types <- c("Depends", "Imports", "Suggests", "Enhances", "LinkingTo")

dependency_type <- unique(dependency_type)
if (!all(dependency_type %in% possible_types) || length(dependency_type) < 1)
stop("'dependency_type' should specify which types of dependencies should be included")
dependency_type <- match_dependency_type(dependency_type)

l_dependency_type <- tolower(dependency_type)
names(dependency_type) <- l_dependency_type
Expand Down Expand Up @@ -98,3 +97,21 @@ get_dependencies <- function(package, downloads = TRUE, bioc = FALSE, local = FA
print.package_dependencies <- function(x, ...) {
print.data.frame(x)
}

#' Match vector of dependency types
#'
#' @inheritParams get_dependencies
#'
#' Based on `tools:::.expand_dependency_type_spec`, according to the suggestion of Dirk Eddelbuettel
#'
#' @noRd
match_dependency_type <- function(dependency_type) {
possible_types <- c("Depends", "Imports", "LinkingTo", "Suggests", "Enhances")

if (identical(dependency_type, "strong")) possible_types[1:3]
else if (identical(dependency_type, "most")) possible_types[1:4]
else if (identical(dependency_type, "all")) possible_types
else if (!all(dependency_type %in% possible_types) || length(dependency_type) < 1)
stop("'dependency_type' should specify which types of dependencies should be included")
else dependency_type
}
26 changes: 16 additions & 10 deletions R/plot_deepdep.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#' displayed below package name. Defaults to \code{FALSE}.
#' @param show_downloads A \code{logical}. If \code{TRUE} total number of downloads of packages
#' will be displayed below package names. Defaults to \code{FALSE}.
#' @param show_stamp A \code{logical}. If \code{TRUE} (the default) the package version and
#' plot creation time will be added
#' @param ... Other arguments passed to the \code{deepdep} function.
#'
#' @return A \code{ggplot2, gg, ggraph, deepdep_plot} class object.
Expand Down Expand Up @@ -48,32 +50,36 @@
#' @rdname plot_deepdep
#' @export
plot_dependencies <- function(x, type = "circular", same_level = FALSE, reverse = FALSE,
label_percentage = 1, show_version = FALSE, show_downloads = FALSE, ...) {
label_percentage = 1, show_version = FALSE, show_downloads = FALSE,
show_stamp = TRUE, ...) {
UseMethod("plot_dependencies")
}

#' @rdname plot_deepdep
#' @export
plot_dependencies.default <- function(x, type = "circular", same_level = FALSE, reverse = FALSE,
label_percentage = 1, show_version = FALSE, show_downloads = FALSE, ...) {
label_percentage = 1, show_version = FALSE, show_downloads = FALSE,
show_stamp = TRUE, ...) {
stop("This type of object does not have implemented method for 'plot_dependencies'")
}

#' @rdname plot_deepdep
#' @export
plot_dependencies.character <- function(x, type = "circular", same_level = FALSE, reverse = FALSE,
label_percentage = 1, show_version = FALSE, show_downloads = FALSE, ...) {
label_percentage = 1, show_version = FALSE, show_downloads = FALSE,
show_stamp = TRUE, ...) {
package_name <- NULL
if (show_downloads == TRUE || label_percentage < 1)
dd <- deepdep(x, downloads = TRUE, ...)
else dd <- deepdep(x, ...)
plot_dependencies(dd, type, same_level, reverse, label_percentage, show_version, show_downloads)
plot_dependencies(dd, type, same_level, reverse, label_percentage, show_version, show_downloads, show_stamp)
}

#' @rdname plot_deepdep
#' @export
plot_dependencies.deepdep <- function(x, type = "circular", same_level = FALSE, reverse = FALSE,
label_percentage = 1, show_version = FALSE, show_downloads = FALSE, ...) {
label_percentage = 1, show_version = FALSE, show_downloads = FALSE,
show_stamp = TRUE, ...) {
# Due to NSE inside of the function, we have to declare "labeled" as NULL to prevent check fail
labeled <- NULL
node1.name <- NULL
Expand Down Expand Up @@ -144,11 +150,11 @@ plot_dependencies.deepdep <- function(x, type = "circular", same_level = FALSE,
aes(label = name, fill = factor(layer)),
show.legend = FALSE,
label.padding = unit(0.28, "lines")) +
default_nodefill_scale(length(levels(factor(V(G)$layer)))) +
labs(caption = paste0("Plot made with deepdep v",
packageVersion("deepdep"),
" on ", format(Sys.time(), usetz = FALSE))
)
default_nodefill_scale(length(levels(factor(V(G)$layer))))
if (show_stamp)
g <- g + labs(caption = paste0("Plot made with deepdep v",
packageVersion("deepdep"),
" on ", format(Sys.time(), usetz = FALSE)))

class(g) <- c(class(g), "deepdep_plot")
g
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ head(dd_xgboost)
```

## origin name version type last_day last_week last_month last_quarter last_half grand_total origin_level dest_level
## 1 xgboost Matrix >= 1.1-0 Imports 1861 29118 116069 314379 715420 6726824 0 1
## 2 xgboost data.table >= 1.9.6 Imports 18594 205828 890362 2556360 4586475 30727748 0 1
## 3 xgboost jsonlite >= 1.0 Imports 21610 234767 990987 3494965 6879236 50867651 0 1
## 1 xgboost Matrix >= 1.1-0 Imports 4454 24384 120814 335932 676904 6818520 0 1
## 2 xgboost data.table >= 1.9.6 Imports 35829 203788 847404 2665713 4659980 31369324 0 1
## 3 xgboost jsonlite >= 1.0 Imports 36025 246923 1005752 3362575 6707399 51638636 0 1

``` r
plot_downloads(dd_xgboost)
Expand Down
Binary file modified README_files/figure-gfm/unnamed-chunk-2-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed README_files/figure-gfm/unnamed-chunk-2-2.png
Binary file not shown.
Binary file modified README_files/figure-gfm/unnamed-chunk-3-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-gfm/unnamed-chunk-4-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed README_files/figure-gfm/unnamed-chunk-4-2.png
Binary file not shown.
Binary file modified README_files/figure-gfm/unnamed-chunk-5-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 8 additions & 22 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
@@ -1,34 +1,20 @@
andrie
api
AppVeyor
behaviour
bioconductor
Cheatsheet
Bioc
CircleCI
Codecov
cran
crandb
DependenciesGraphs
Github
Lifecycle
RCurl
andrie
api
cranlogs
datastorm
dep
deepdep
DependenciesGraphs
github
http
https
donttest
igraph
interactively
iteratively
Lifecycle
LinkingTo
md
miniCRAN
org
pkg
pkgDepTools
pkgnet
RCurl
README
rstudio
RStudio
vactor
9 changes: 6 additions & 3 deletions man/get_dependencies.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions man/plot_deepdep.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 982f153

Please sign in to comment.