to_cumulative_id: Give Each Field in a Subdirectory Matrix an ID

Description Usage Arguments Examples

View source: R/to_cumulative_id.R

Description

In the subdir matrix, each row represents a file path. The different parts of the paths (the folder names) appear in the different columns. For example, the paths "a/b/c" and "d/e" are represented by a matrix with values "a", "b", "c" in the first and "d", "e", "" in the second row. Each cell of the subdir matrix that is not empty gets a number. If two cells of one column have the same number, this means that the paths to the cells are the same. See example.

Usage

1

Arguments

subdirs

matrix of subdirectory names, as returned by to_subdir_matrix

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# Create a very simple subdirectory matrix
(subdirs <- matrix(byrow = TRUE, ncol = 4, c(
  "a", "b", "c", "d",
  "a", "b", "d", "",
  "a", "c", "d", "e"
)))

# Give each non-empty cell of the matrix an ID
kwb.pathdict:::to_cumulative_id(subdirs)

# You can read the matrix column by column. The highest number represents the
# number of different paths that reach up to the corresponding path level.
# 1st column: The starting parts of the paths in depth 1 are the same: "a".
#  All cells have ID = 1.
# 2nd column: There are two different paths to the folders in depth 2:
#   "a/b" (ID = 1) and "a/c" (ID = 2).
# 3rd column: There are three different paths to the folders in depth 3:
#   "a/b/c" (ID = 1), "a/b/d" (ID = 2), "a/c/d" (ID = 3).
# 4th column: There are only two out of three paths that reach depth 4:
#   "a/b/c/d" (ID = 1), "a/c/d/e" (ID = 2)

KWB-R/kwb.pathdict documentation built on Jan. 13, 2020, 2:24 a.m.