prepare_path_data: Select and Filter for Relevant Path Information

View source: R/prepare_path_data.R

prepare_path_dataR Documentation

Select and Filter for Relevant Path Information

Description

This function gets a data frame containing path information as input. It filters for rows with value "file" in column type and keeps only the columns path and size. If pattern is not NULL, the data frame is then filtered for rows in which path matches the given pattern. Finally, the common root of all paths in column path is removed and the resulting data frame is returned.

Usage

prepare_path_data(path_info, pattern = NULL)

Arguments

path_info

data frame containing file path information as returned by read_file_info

pattern

pattern by which to select a subset of paths or NULL (default) if all paths in path_info are to be considered. By setting the pattern to "^/path/to/start/directory" you can "zoom into" the path tree, returning only the contents of "/path/to/start/directory".

Value

data frame with columns path and size. See Description.

Examples

path_info <- kwb.utils::noFactorDataFrame(
  path = c("/path/to/root/", "/path/to/root/file_1", "/path/to/root/file_2"),
  type = c("directory", "file", "file"),
  size = c(0L, 10L, 20L)
)

path_info

kwb.fakin:::prepare_path_data(path_info)

KWB-R/kwb.fakin documentation built on June 14, 2022, 2 p.m.