repo_dependencies: Build and/or plots a dependency graph

Description Usage Arguments Details Value Examples

View source: R/repo_public.R

Description

Creates a weighted adjacency matrix, in which (i,j) = x means that item i is in relation x with item j. The resulting graph is plotted.

Usage

1
2
3
4
5
6
7
8
9
repo_dependencies(
  tags = NULL,
  tagfun = "OR",
  depends = T,
  attached = T,
  generated = T,
  plot = T,
  ...
)

Arguments

tags

Only show nodes matching tags

tagfun

Function specifying how to match tags (by default "OR": match any of tags).

depends

If TRUE, show "depends on" edges.

attached

If TRUE, show "attached to" edges.

generated

If TRUE, show "generated by" edges.

plot

If TRUE (default), plot the dependency graph.

...

Other parameters passed to the plot.igraph function.

Details

The relation between any two items i and j can have values 1, 2 or 3, respectively meaning:

Value

Adjacency matrix representing the graph, with edges labeled 1, 2, 3 corresponding to "depends", "attached" and "generated" respectively.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
## Repository creation
rp_path <- file.path(tempdir(), "example_repo")
rp <- repo_open(rp_path, TRUE)

## Producing some irrelevant data
data1 <- 1:10
data2 <- data1 * 2
data3 <- data1 + data2

## Putting the data in the database, specifying dependencies
rp$put(data1, "item1", "First item",
    "repo_dependencies")
rp$put(data2, "item2", "Item dependent on item1", 
    "repo_dependencies", depends="item1")
rp$put(data3, "item3", "Item dependent on item1 and item2",
    "repo_dependencies", depends=c("item1", "item2"))

## Creating a temporary plot and attaching it
fpath <- file.path(rp$root(), "temp.pdf")
pdf(fpath)
plot(data1)
dev.off()
rp$attach(fpath, "visualization of item1", "plot",
   to="item1")

## Obtaining the dependency matrix
depmat <- rp$dependencies(plot=FALSE)
print(depmat)
## The matrix can be plotted as a graph (requires igraph package)
rp$dependencies()
## The following hides "generated" edges
rp$dependencies(generated=FALSE)

## wiping temporary repo
unlink(rp_path, TRUE)

franapoli/repo documentation built on May 17, 2021, 7:24 p.m.