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.

to_cumulative_id(subdirs)

Arguments

subdirs

matrix of subdirectory names, as returned by to_subdir_matrix

Examples

# Create a very simple subdirectory matrix (subdirs <- matrix(byrow = TRUE, ncol = 4, c( "a", "b", "c", "d", "a", "b", "d", "", "a", "c", "d", "e" )))
#> [,1] [,2] [,3] [,4] #> [1,] "a" "b" "c" "d" #> [2,] "a" "b" "d" "" #> [3,] "a" "c" "d" "e"
# Give each non-empty cell of the matrix an ID kwb.pathdict:::to_cumulative_id(subdirs)
#> depth: 00 1 2 3 4
#> [,1] [,2] [,3] [,4] #> [1,] 1 1 1 1 #> [2,] 1 1 2 NA #> [3,] 1 2 3 2
# 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)