prepare_df | R Documentation |
Constructs a tidy data frame from matched lines across a set of files.
This function takes the output of read_filter_lines()
and returns one row per match,
including file path, line number, full line content, and regex match(es).
prepare_df(files, pattern, lines, path, relative_path, matches)
files |
A character vector of files to search (only for |
pattern |
A regular expression pattern used to match lines. |
lines |
A list with |
path |
A character vector of one or more directories where files should be
discovered (only for |
relative_path |
Logical. If TRUE, file paths are made relative to the path argument. If multiple root paths are provided, relative_path is automatically ignored and absolute paths are kept to avoid ambiguity. |
matches |
Logical. If |
All steps are executed sequentially to transform file-based pattern matches into a structured tabular format.
The function assumes that input files and their corresponding line data are correctly aligned.
It handles path normalization, match extraction, and output column selection according to the matches
and relative_path
arguments.
A tibble with the following columns:
path
: File path (relative if specified), marked with class fs_path
.
line_number
: Line number of the match within the file.
match
: The first matched substring from the line.
matches
(optional): All matched substrings as a list-column.
line
: Full content of the matching line.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.