Convert a Vector of Paths to a Matrix of Subfolders

to_subdir_matrix(paths, fill.value = "", result_type = "matrix",
  dbg = FALSE, method = NA_integer_)

Arguments

paths

vector of path strings

fill.value

value used to fill empty cells of the result matrix

result_type

one of c("matrix", "data.frame", "list"), specifying the type of object to be returned. Result type "list" is only implemented for method = 2.

dbg

if TRUE debug messages are shown

method

integer specifying the implementation method. Currently not used.

Value

matrix or data frame, depending on result_type

Examples

folder_matrix <- kwb.file::to_subdir_matrix(c("a1/b1/c1", "a1/b2", "a2")) folder_matrix
#> [,1] [,2] [,3] #> [1,] "a1" "b1" "c1" #> [2,] "a1" "b2" "" #> [3,] "a2" "" ""
dim(folder_matrix)
#> [1] 3 3
folder_matrix[folder_matrix[, 1] == "a1", ]
#> [,1] [,2] [,3] #> [1,] "a1" "b1" "c1" #> [2,] "a1" "b2" ""