Skip to content

Commit

Permalink
Further cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
hsonne committed May 6, 2024
1 parent a6dbfb1 commit d6c0709
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 48 deletions.
6 changes: 2 additions & 4 deletions R/downloadPackagesFromSnapshot.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@ downloadPackagesFromSnapshot <- function(
repos <- getUrl("mran_snapshot", date = snapshot_date)

if (is.null(destdir)) {

success <- dir.create(destdir <- tempfile("snapshot_"))

destdir <- tempfile("snapshot_")
success <- dir.create(destdir)
} else {

stopifnot(file.exists(destdir))
}

Expand Down
17 changes: 6 additions & 11 deletions R/getPackageLicences.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,12 @@ getPackageLicences <- function(
licence_fields <- grep("^licence", names(db), value = TRUE)
stopifnot(length(licence_fields) > 0L)

backbone <- data.frame(
package = packages,
stringsAsFactors = FALSE
)

result <- backbone %>%
merge(
y = selectColumns(db, c("package", "version", licence_fields)),
by = "package",
all.x = TRUE
) %>%
merge(
x = noFactorDataFrame(package = packages),
y = selectColumns(db, c("package", "version", licence_fields)),
by = "package",
all.x = TRUE
) %>%
renameColumns(list(license = "licence")) %>%
orderBy("package")

Expand Down
5 changes: 4 additions & 1 deletion R/local_cran.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ defaultLocalCRAN <- function(drive_letter = FALSE)
# Since there are problems with the network path //moby/miacso$ we need to
# map this network path to a drive letter (here: U:)
servername <- getServername()
file.path(ifelse(drive_letter, "U:", sprintf("\\\\%s/miacso$", servername)), "local-cran")
file.path(
ifelse(drive_letter, "U:", sprintf("\\\\%s/miacso$", servername)),
"local-cran"
)
}

# getBinaryPaths ---------------------------------------------------------------
Expand Down
12 changes: 7 additions & 5 deletions R/packageDependenciesByType.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,15 @@ packageDependenciesByType <- function(
verbose = verbose
)[[1L]]

if (length(dependencies)) {
data.frame(
package = packages,
type = rep(type, length(dependencies))
)
if (length(dependencies) == 0L) {
return(NULL)
}

data.frame(
package = packages,
type = rep(type, length(dependencies))
)

}) %>%
stats::setNames(which) %>%
excludeNULL(dbg = FALSE) %>%
Expand Down
4 changes: 2 additions & 2 deletions R/plotAllDependencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ plotNodes <- function(nodes, r = 1, col = "red", ...)
#'
#' @param nodes data frame as returned by \code{\link{toNodes}}
#' @param cex character expansion factor as given to \code{text}
#' @param distance.factor expansion factor applied to the x and y coordinates of the nodes to get
#' the coordinates of the labels
#' @param distance.factor expansion factor applied to the x and y coordinates of
#' the nodes to get the coordinates of the labels
#' @export
addNodeLabels <- function(nodes, cex = 1, distance.factor = 1)
{
Expand Down
7 changes: 0 additions & 7 deletions R/remotes_imports.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
# remotes_github_pat -----------------------------------------------------------
remotes_github_pat <- getFromNamespace("github_pat", "remotes")

# remotes_parse_deps -----------------------------------------------------------
remotes_parse_deps <- getFromNamespace("parse_deps", "remotes")

# remotes_read_dcf -------------------------------------------------------------
remotes_read_dcf <- getFromNamespace("read_dcf", "remotes")

# remotes_untar_description ----------------------------------------------------
remotes_untar_description <- getFromNamespace("untar_description", "remotes")
43 changes: 27 additions & 16 deletions R/sankey_network.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,15 @@ plotSankeyNetwork <- function(functionName, where = 1, ...)
network <- toLinksAndNodes(relationMatrixToSourceTarget(x = relations))

networkD3::sankeyNetwork(
network$links, network$nodes, Source = "source", Target = "target",
Value = "value", NodeID = "name", NodeGroup = "name",
nodeWidth = 10, nodePadding = 25,
network$links,
network$nodes,
Source = "source",
Target = "target",
Value = "value",
NodeID = "name",
NodeGroup = "name",
nodeWidth = 10,
nodePadding = 25,
fontSize = 10
)
}
Expand All @@ -35,22 +41,19 @@ plotSankeyNetwork <- function(functionName, where = 1, ...)
#' Package String
#'
#' @param package Package name
#'
#' @return \code{package}, preceded by \code{package:}
#'
#' @export
#'
packageString <- function(package)
{
paste0("package:", package)
}

# exampleLinksAndNodes --------------------------------------------------------
# exampleLinksAndNodes ---------------------------------------------------------

#' Example Links and Nodes
#'
#' @export
#' @importFrom utils read.table

exampleLinksAndNodes <- function()
{
list(
Expand Down Expand Up @@ -113,6 +116,7 @@ toLinksAndNodes <- function(links)
}

# toSourceTarget ---------------------------------------------------------------

#' @noMd
#' @noRd
#' @keywords internal
Expand All @@ -123,17 +127,16 @@ toSourceTarget <- function(x)
lastcaller <- character()

for (i in seq_len(nrow(x))) {

L <- x$level[i]
x$caller[i] <- if (L > 1) lastcaller[L - 1] else NA
lastcaller[L] <- x$target[i]
}

renameColumns(x[, c("caller", "target")], list(caller = "source"))
x[, c("caller", "target")] %>%
renameColumns(list(caller = "source"))
}

# includeExclude ---------------------------------------------------------------

includeExclude <- function(x, exclude = NULL)
{
if (! is.null(exclude)) {
Expand All @@ -148,14 +151,22 @@ includeExclude <- function(x, exclude = NULL)
}

# relationMatrixToSourceTarget -------------------------------------------------

#' @noMd
#' @noRd
#' @keywords internal
relationMatrixToSourceTarget <- function(x)
{
rbindAll(lapply(rownames(x), function(rowname) {
if (length(names.x <- names(which(x[rowname, ] == 1)))) {
data.frame(source = rowname, target = names.x)
}
}))
rownames(x) %>%
lapply(function(rowname) {
names.x <- names(which(x[rowname, ] == 1))
if (length(names.x) == 0L) {
return(NULL)
}
data.frame(
source = rowname,
target = names.x
)
}) %>%
rbindAll()
}
4 changes: 2 additions & 2 deletions man/addNodeLabels.Rd

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

0 comments on commit d6c0709

Please sign in to comment.